diff --git a/.gitignore b/.gitignore index 5e35a743844..08e774f3380 100644 --- a/.gitignore +++ b/.gitignore @@ -95,6 +95,7 @@ test.sh /js/dist/* /css/dist/* /packages/*/dist +/blocks/** yarn-error.log coverage dependencies.json @@ -108,4 +109,4 @@ dependencies.md ############ /.tmp -.cache/phpunit/cache/ \ No newline at end of file +.cache/phpunit/cache/ diff --git a/config/grunt/task-config/copy.js b/config/grunt/task-config/copy.js index c95a555944f..20e4c1dda95 100644 --- a/config/grunt/task-config/copy.js +++ b/config/grunt/task-config/copy.js @@ -28,6 +28,7 @@ module.exports = { "packages/js/images/**", "inc/**", "<%= paths.jsDist %>/**/*.js", + "blocks/**", "languages/**", "src/**", "lib/**", diff --git a/config/webpack/webpack.config.base.js b/config/webpack/webpack.config.base.js index 3c82c356d74..8e7e21df2b3 100644 --- a/config/webpack/webpack.config.base.js +++ b/config/webpack/webpack.config.base.js @@ -10,7 +10,7 @@ const { yoastExternals } = require( "./externals" ); let analyzerPort = 8888; -module.exports = function( { entry, output, combinedOutputFile, cssExtractFileName } ) { +module.exports = function( { entry, output, combinedOutputFile, cssExtractFileName, plugins = [] } ) { return { ...defaultConfig, optimization: { @@ -95,6 +95,7 @@ module.exports = function( { entry, output, combinedOutputFile, cssExtractFileNa // Copied from WP config: Inject the `SCRIPT_DEBUG` global, used for development features flagging. SCRIPT_DEBUG: process.env.NODE_ENV !== "production", } ), + ...plugins, ].filter( Boolean ), }; }; diff --git a/config/webpack/webpack.config.js b/config/webpack/webpack.config.js index c52cae71095..bc5011a2ee1 100644 --- a/config/webpack/webpack.config.js +++ b/config/webpack/webpack.config.js @@ -1,6 +1,7 @@ // External dependencies +const CopyWebpackPlugin = require( "copy-webpack-plugin" ); const { readdirSync } = require( "fs" ); -const { join } = require( "path" ); +const { join, resolve } = require( "path" ); // Variables const root = join( __dirname, "../../" ); @@ -29,6 +30,17 @@ module.exports = [ }, combinedOutputFile: root + "src/generated/assets/plugin.php", cssExtractFileName: "../../../css/dist/plugin-" + pluginVersionSlug + ".css", + plugins: [ + new CopyWebpackPlugin( { + patterns: [ + { + from: "**/block.json", + context: "packages/js/src", + to: resolve( "blocks" ), + }, + ], + } ), + ], } ), baseConfig(