Newly Paranoid Maintainers

    @tinypixelco/laravel-mix-wp-blocks

    1.1.0 • Public • Published

    Laravel Mix WP Blocks

    Maintainability npm version

    About

    Laravel mix extension to transpile WordPress block scripts.

    Installation

    npm install @tinypixelco/laravel-mix-wp-blocks --save-dev
    yarn add -D @tinypixelco/laravel-mix-wp-blocks

    Usage

    In webpack.config.js:

    require("@tinypixelco/laravel-mix-wp-blocks")
    
    mix.block('resources/assets/scripts/blocks.js', 'scripts')

    By doing so you'll find that you can now utilize all @wordpress scoped dependencies using ECMAScript 6 import syntax. Example:

    import { RichText } from '@wordpress/block-editor'

    These packages are included as webpack externals, so there is no reason to add them to your package file.

    You will also find a php manifest file accompanying each script in your distribution directory. This file declares an array of dependencies based on what you've used in your scripts. Require it and you're set.

    Additional Dependency Extraction Webpack Plugin options maybe be provided as a third argument to mix.block():

    mix.block('resources/assets/scripts/blocks.js', 'scripts', {
      outputFormat: 'json',
    })

    Besides the plugin options there is a special flag for the common use case of turning off @babel/runtime/regenerator handling by wp-polyfill.

    mix.block('resources/assets/scripts/blocks.js', 'scripts', {
      disableRegenerator: true,
    })

    Install

    npm i @tinypixelco/laravel-mix-wp-blocks

    DownloadsWeekly Downloads

    1,379

    Version

    1.1.0

    License

    MIT

    Unpacked Size

    4.73 kB

    Total Files

    4

    Last publish

    Collaborators

    • kellymears