diff --git a/webpack.config.js b/webpack.config.js index 849b686..0e01fce 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -29,7 +29,7 @@ const blockEntryPaths = glob const entryKey = filePath .replace('./assets/blocks/', '') .replace('/index.js', ''); - acc[`../blocks/${entryKey}`] = filePath; + acc[`../blocks/${entryKey}/index`] = filePath; return acc; }, {}); @@ -39,7 +39,7 @@ const blockScssPaths = glob const entryKey = filePath .replace('./assets/blocks/', '') .replace('/style.scss', ''); - acc[`../blocks/${entryKey}`] = filePath; + acc[`../blocks/${entryKey}/style`] = filePath; return acc; }, {}); @@ -51,6 +51,28 @@ const styleScssPaths = glob return acc; }, {}); +// CopyPlugin patterns to include PHP and JSON files +const copyPluginPatterns = [ + { + from: './assets/blocks/**/*.php', + to: ({ context, absoluteFilename }) => { + return absoluteFilename.replace( + `${context}/assets/blocks/`, + '../blocks/' + ); + }, + }, + { + from: './assets/blocks/**/*.json', + to: ({ context, absoluteFilename }) => { + return absoluteFilename.replace( + `${context}/assets/blocks/`, + '../blocks/' + ); + }, + }, +]; + module.exports = { ...defaultConfig, entry: { @@ -177,6 +199,7 @@ module.exports = { context: path.resolve(process.cwd(), 'assets/fonts'), noErrorOnMissing: true, }, + ...copyPluginPatterns, // Include patterns for PHP and JSON files ], }),