implements ignorePath for webpack server side assets
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
const HtmlWebpackPlugin = require('html-webpack-plugin');
|
||||
const Dotenv = require('dotenv-webpack');
|
||||
// const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer');
|
||||
const { IgnorePlugin } = require('webpack');
|
||||
const path = require('path');
|
||||
const getStyleLoaders = require('./getStyleLoaders');
|
||||
|
||||
@@ -104,17 +105,6 @@ module.exports = (config) => {
|
||||
},
|
||||
],
|
||||
},
|
||||
plugins: [
|
||||
// new BundleAnalyzerPlugin(),
|
||||
new HtmlWebpackPlugin({
|
||||
template: path.resolve(__dirname, '../client/index.html'),
|
||||
filename: './index.html',
|
||||
minify: true,
|
||||
}),
|
||||
new Dotenv({
|
||||
silent: true,
|
||||
}),
|
||||
],
|
||||
resolve: {
|
||||
modules: ['node_modules', path.resolve(__dirname, '../../node_modules')],
|
||||
alias: {
|
||||
@@ -124,6 +114,36 @@ module.exports = (config) => {
|
||||
},
|
||||
};
|
||||
|
||||
const plugins = [
|
||||
// new BundleAnalyzerPlugin(),
|
||||
new HtmlWebpackPlugin({
|
||||
template: path.resolve(__dirname, '../client/index.html'),
|
||||
filename: './index.html',
|
||||
minify: true,
|
||||
}),
|
||||
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 {
|
||||
@@ -131,7 +151,7 @@ module.exports = (config) => {
|
||||
}
|
||||
|
||||
if (config.webpack && typeof config.webpack === 'function') {
|
||||
webpackConfig = config.webpack(webpackConfig);
|
||||
webpackConfig = config.webpack(webpackConfig, 'production');
|
||||
}
|
||||
|
||||
return webpackConfig;
|
||||
|
||||
Reference in New Issue
Block a user