Open james0r opened 5 months ago
At this point - the --experimental-modules
flag does not support using a custom webpack config file. If you want to use the Interactivity API, you'll need to build those blocks in a separate plugin.
Even if there could be a way to modify our custom webpack config to work with it, it's still an 'experimental' feature, so I'm waiting to see what core is going to do about it first before adapting any code.
@james0r Could you please try the below code. https://github.com/rabindratharu/boilerplate/blob/experimental/webpack.config.js
const { getWebpackEntryPoints } = require('@wordpress/scripts/utils/config');
// External dependencies
const path = require( 'path' );
const RemoveEmptyScriptsPlugin = require( 'webpack-remove-empty-scripts' );
const CssMinimizerPlugin = require("css-minimizer-webpack-plugin");
// JS Directory path.
const SRC_DIR = path.resolve( __dirname, 'src' );
const entry = {
...getWebpackEntryPoints('script')(),
public: SRC_DIR + '/public/index.js'
};
const isProduction = process.env.NODE_ENV === 'production';
module.exports = [
{
...scriptConfig,
entry: entry,
module: {
...scriptConfig.module,
rules: [
...scriptConfig.module.rules,
],
},
optimization: {
minimize: isProduction,
minimizer: [
'...',
new CssMinimizerPlugin()
]
},
plugins: [
...scriptConfig.plugins,
new RemoveEmptyScriptsPlugin(),
],
},
moduleConfig,
];
Just curious if theres a recommended way to set up blocks using the Interactivity API with block-theme.
Looks like with the current @wordpress/wp-scripts version we need to add the
--experimental-modules
flag, but using this flag breaks the provided WebPack config overrides.Error thrown for