Skip to content

Commit

Permalink
Fix webpack file name conflict
Browse files Browse the repository at this point in the history
scss files with same name as js files prevented the js files to be transpiled
  • Loading branch information
SimonMayerhofer committed May 11, 2021
1 parent e250c0b commit eee6b45
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions tasks/options/webpack.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,18 @@ entries = entries.reduce((acc, filepath) => {
const name = filepath.match(filenameRegex)[1];

if (isJSBlock(filepath)) {
acc[name] = {
acc[`jsblock_${name}`] = {
import: filepath,
filename: 'blocks/[name].js',
filename: `blocks/${name}.js`,
dependOn: 'app',
};
} else if (isSCSSFile(filepath)) {
const subfolderRegex = /\/scss\/([\w\d_-]*\/)?([\w\d_-]*)\.scss$/i;
const subfolder = filepath.match(subfolderRegex)[1];

acc[name] = {
acc[`scss_${name}`] = {
import: filepath,
filename: `scss/${subfolder || ''}[name].js`,
filename: `scss/${subfolder || ''}${name}.js`,
};
} else {
acc[name] = filepath;
Expand Down Expand Up @@ -84,7 +84,8 @@ module.exports = {
const filepath = pathData.chunk.filenameTemplate;
const subfolderRegex = /scss\/([\w\d_-]*\/)?([\w\d_\-[\]]*)\.js$/i;
const subfolder = filepath.match(subfolderRegex)[1];
return `../css/${subfolder || ''}[name].css`;
const filename = filepath.match(subfolderRegex)[2];
return `../css/${subfolder || ''}${filename}.css`;
},
}),
new CopyWebpackPlugin({
Expand Down

0 comments on commit eee6b45

Please sign in to comment.