Skip to content

Commit

Permalink
WDSBT-20 - Fix blocks output directory path
Browse files Browse the repository at this point in the history
  • Loading branch information
khleomix committed Jun 18, 2024
1 parent 1de160b commit cd82a16
Showing 1 changed file with 25 additions and 2 deletions.
27 changes: 25 additions & 2 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}, {});

Expand All @@ -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;
}, {});

Expand All @@ -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: {
Expand Down Expand Up @@ -177,6 +199,7 @@ module.exports = {
context: path.resolve(process.cwd(), 'assets/fonts'),
noErrorOnMissing: true,
},
...copyPluginPatterns, // Include patterns for PHP and JSON files
],
}),

Expand Down

0 comments on commit cd82a16

Please sign in to comment.