implements ignorePath for webpack server side assets

This commit is contained in:
James
2020-07-18 15:10:50 -04:00
parent 6533ce0e24
commit 243ca9a7f9
2 changed files with 62 additions and 22 deletions

View File

@@ -1,4 +1,5 @@
const HtmlWebpackPlugin = require('html-webpack-plugin');
const { IgnorePlugin } = require('webpack');
const path = require('path');
const webpack = require('webpack');
const Dotenv = require('dotenv-webpack');
@@ -116,16 +117,6 @@ module.exports = (config) => {
},
],
},
plugins: [
new HtmlWebpackPlugin({
template: path.resolve(__dirname, '../client/index.html'),
filename: './index.html',
}),
new webpack.HotModuleReplacementPlugin(),
new Dotenv({
silent: true,
}),
],
resolve: {
modules: ['node_modules', path.resolve(__dirname, '../../node_modules')],
alias: {
@@ -135,6 +126,35 @@ module.exports = (config) => {
},
};
const plugins = [
new HtmlWebpackPlugin({
template: path.resolve(__dirname, '../client/index.html'),
filename: './index.html',
}),
new webpack.HotModuleReplacementPlugin(),
new Dotenv({
silent: true,
}),
];
if (config.webpackIgnorePlugin instanceof RegExp) {
plugins.push(new IgnorePlugin(config.webpackIgnorePlugin));
} else if (typeof config.webpackIgnorePlugin === 'string') {
plugins.push(new IgnorePlugin(new RegExp(`^${config.webpackIgnorePlugin}$`, 'is')));
}
if (Array.isArray(config.webpackIgnorePlugin)) {
config.webpackIgnorePlugin.forEach((ignorePath) => {
if (ignorePath instanceof RegExp) {
plugins.push(new IgnorePlugin(ignorePath));
} else if (typeof ignorePath === 'string') {
plugins.push(new IgnorePlugin(new RegExp(`^${ignorePath}$`, 'is')));
}
});
}
webpackConfig.plugins = plugins;
if (config.paths.scss) {
webpackConfig.resolve.alias['payload-scss-overrides'] = config.paths.scss;
} else {