Skip to content

Commit cd82a16

Browse files
committed
WDSBT-20 - Fix blocks output directory path
1 parent 1de160b commit cd82a16

File tree

1 file changed

+25
-2
lines changed

1 file changed

+25
-2
lines changed

webpack.config.js

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ const blockEntryPaths = glob
2929
const entryKey = filePath
3030
.replace('./assets/blocks/', '')
3131
.replace('/index.js', '');
32-
acc[`../blocks/${entryKey}`] = filePath;
32+
acc[`../blocks/${entryKey}/index`] = filePath;
3333
return acc;
3434
}, {});
3535

@@ -39,7 +39,7 @@ const blockScssPaths = glob
3939
const entryKey = filePath
4040
.replace('./assets/blocks/', '')
4141
.replace('/style.scss', '');
42-
acc[`../blocks/${entryKey}`] = filePath;
42+
acc[`../blocks/${entryKey}/style`] = filePath;
4343
return acc;
4444
}, {});
4545

@@ -51,6 +51,28 @@ const styleScssPaths = glob
5151
return acc;
5252
}, {});
5353

54+
// CopyPlugin patterns to include PHP and JSON files
55+
const copyPluginPatterns = [
56+
{
57+
from: './assets/blocks/**/*.php',
58+
to: ({ context, absoluteFilename }) => {
59+
return absoluteFilename.replace(
60+
`${context}/assets/blocks/`,
61+
'../blocks/'
62+
);
63+
},
64+
},
65+
{
66+
from: './assets/blocks/**/*.json',
67+
to: ({ context, absoluteFilename }) => {
68+
return absoluteFilename.replace(
69+
`${context}/assets/blocks/`,
70+
'../blocks/'
71+
);
72+
},
73+
},
74+
];
75+
5476
module.exports = {
5577
...defaultConfig,
5678
entry: {
@@ -177,6 +199,7 @@ module.exports = {
177199
context: path.resolve(process.cwd(), 'assets/fonts'),
178200
noErrorOnMissing: true,
179201
},
202+
...copyPluginPatterns, // Include patterns for PHP and JSON files
180203
],
181204
}),
182205

0 commit comments

Comments
 (0)