diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..0f807ab --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,17 @@ +name: npm publish +on: + workflow_dispatch: +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + # Setup .npmrc file to publish to npm + - uses: actions/setup-node@v3 + with: + node-version: "16.x" + registry-url: "https://registry.npmjs.org" + - run: npm ci + - run: npm publish + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/CHANGELOG.md b/CHANGELOG.md index e39b0dd..54a8e72 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## 1.2.0 Sept 5, 2022 + +- [fix: update for >=6.0.43](https://github.com/pixelcollective/laravel-mix-wp-blocks/pull/7) by [@joshuafredrickson](https://github.com/joshuafredrickson) + ## 1.1.0 May 24th, 2020 ### Added diff --git a/README.md b/README.md index 448651f..27f9efb 100644 --- a/README.md +++ b/README.md @@ -21,15 +21,15 @@ yarn add -D @tinypixelco/laravel-mix-wp-blocks In webpack.config.js: ```js -require("@tinypixelco/laravel-mix-wp-blocks") +require("@tinypixelco/laravel-mix-wp-blocks"); -mix.block('resources/assets/scripts/blocks.js', 'scripts') +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: ```js -import { RichText } from '@wordpress/block-editor' +import { RichText } from "@wordpress/block-editor"; ``` These packages are included as [webpack externals](https://webpack.js.org/configuration/externals/), so there is no reason to add them to your package file. @@ -39,15 +39,15 @@ You will also find a php manifest file accompanying each script in your distribu Additional [Dependency Extraction Webpack Plugin options](https://www.npmjs.com/package/@wordpress/dependency-extraction-webpack-plugin#options) maybe be provided as a third argument to `mix.block()`: ```js -mix.block('resources/assets/scripts/blocks.js', 'scripts', { - outputFormat: 'json', -}) +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`. ```js -mix.block('resources/assets/scripts/blocks.js', 'scripts', { +mix.block("resources/assets/scripts/blocks.js", "scripts", { disableRegenerator: true, -}) -``` \ No newline at end of file +}); +``` diff --git a/index.js b/index.js index 9592c3a..7e5cf84 100644 --- a/index.js +++ b/index.js @@ -1,6 +1,6 @@ -const mix = require('laravel-mix') -const JavaScript = require('laravel-mix/src/components/JavaScript') -const DependencyExtractionPlugin = require('@wordpress/dependency-extraction-webpack-plugin') +const mix = require("laravel-mix"); +const JavaScript = require("laravel-mix/src/components/JavaScript"); +const DependencyExtractionPlugin = require("@wordpress/dependency-extraction-webpack-plugin"); /** * Laravel Mix WP Block @@ -11,12 +11,13 @@ const DependencyExtractionPlugin = require('@wordpress/dependency-extraction-web class Block extends JavaScript { constructor() { super(); - this.context = Mix + this.context = Mix; } - + name() { - return ['blocks', 'block'] + return ["blocks", "block"]; } + /** * All dependencies that should be installed by Mix. * @@ -25,12 +26,12 @@ class Block extends JavaScript { dependencies() { this.requiresReload = ` Dependencies have been installed. Please run again. - ` + `; return [ - '@wordpress/babel-preset-default', - '@wordpress/dependency-extraction-webpack-plugin', - ] + "@wordpress/babel-preset-default", + "@wordpress/dependency-extraction-webpack-plugin", + ]; } /** @@ -42,18 +43,19 @@ class Block extends JavaScript { * @return {void} */ register(entry, output, options = {}) { - this.pluginOptions = ( - options.disableRegenerator === true ? { - ...options, - requestToExternal: function(request) { - if (request === '@babel/runtime/regenerator') { - return null + this.pluginOptions = + options.disableRegenerator === true + ? { + ...options, + requestToExternal: function (request) { + if (request === "@babel/runtime/regenerator") { + return null; + } + }, } - }, - } : options - ) + : options; - super.register(entry, output) + super.register(entry, output); } /** @@ -64,7 +66,7 @@ class Block extends JavaScript { webpackPlugins() { return new DependencyExtractionPlugin({ ...this.pluginOptions, - }) + }); } /** @@ -74,10 +76,10 @@ class Block extends JavaScript { */ babelConfig() { return { - presets: ['@wordpress/babel-preset-default'], - } + presets: ["@wordpress/babel-preset-default"], + }; } } -mix.extend('block', new Block()) -mix.extend('blocks', new Block()) +mix.extend("block", new Block()); +mix.extend("blocks", new Block()); diff --git a/package.json b/package.json index 564908e..597bf80 100644 --- a/package.json +++ b/package.json @@ -1,24 +1,20 @@ { "name": "@tinypixelco/laravel-mix-wp-blocks", - "version": "1.1.0", + "version": "1.2.0", "description": "Laravel mix extension to transpile WordPress blocks.", - "main": "index.js", "repository": { "type": "git", "url": "https://github.com/pixelcollective/laravel-mix-wp-blocks" }, "keywords": [ - "laravel", - "mix", "laravel mix", - "wordpress", - "gutenberg", - "react" + "wordpress" ], "author": "Kelly Mears (https://kellymears.me)", "license": "MIT", "bugs": { "url": "https://github.com/pixelcollective/laravel-mix-wp-blocks/issues" }, - "homepage": "https://github.com/pixelcollective/laravel-mix-wp-blocks#readme" -} \ No newline at end of file + "homepage": "https://github.com/pixelcollective/laravel-mix-wp-blocks#readme", + "main": "index.js" +}