Refactor webpack configs (#3170)

* Refactor webpack configs

* Remove unused import
This commit is contained in:
Bruce Berrios 2022-06-20 09:06:22 -04:00 committed by GitHub
parent df2a9e7f01
commit 6668575cea
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 35 deletions

View file

@ -8,6 +8,20 @@ const ExtraWatchWebpackPlugin = require("extra-watch-webpack-plugin");
let circularImports = 0;
const htmlWebpackPlugins = [
"terms-of-service",
"security-policy",
"privacy-policy",
"email-handler",
"das",
].map((name) => {
return new HtmlWebpackPlugin({
filename: `${name}.html`,
template: resolve(__dirname, `../static/${name}.html`),
inject: false,
});
});
/** @type { import('webpack').Configuration } */
const BASE_CONFIG = {
entry: {
@ -96,6 +110,7 @@ const BASE_CONFIG = {
template: resolve(__dirname, "../static/main.html"),
inject: "body",
}),
...htmlWebpackPlugins,
new MiniCssExtractPlugin({
filename: "./css/style.[chunkhash:8].css",
}),

View file

@ -1,22 +1,5 @@
const { resolve } = require("path");
const { merge } = require("webpack-merge");
const BASE_CONFIG = require("./config.base");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const htmlWebpackPlugins = [
"terms-of-service",
"security-policy",
"privacy-policy",
"email-handler",
"das",
].map((name) => {
return new HtmlWebpackPlugin({
filename: `${name}.html`,
template: resolve(__dirname, `../static/${name}.html`),
inject: "body",
cache: false,
});
});
/** @type { import('webpack').Configuration } */
const DEV_CONFIG = {
@ -33,8 +16,6 @@ const DEV_CONFIG = {
overlay: false,
},
},
plugins: htmlWebpackPlugins,
};
module.exports = merge(BASE_CONFIG, DEV_CONFIG);

View file

@ -3,24 +3,9 @@ const { merge } = require("webpack-merge");
const CssMinimizerPlugin = require("css-minimizer-webpack-plugin");
const HtmlMinimizerPlugin = require("html-minimizer-webpack-plugin");
const JsonMinimizerPlugin = require("json-minimizer-webpack-plugin");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const BASE_CONFIG = require("./config.base");
const htmlWebpackPlugins = [
"terms-of-service",
"security-policy",
"privacy-policy",
"email-handler",
"das",
].map((name) => {
return new HtmlWebpackPlugin({
filename: `${name}.html`,
template: resolve(__dirname, `../static/${name}.html`),
inject: false,
});
});
function pad(numbers, maxLength, fillString) {
return numbers.map((number) =>
number.toString().padStart(maxLength, fillString)
@ -79,7 +64,6 @@ const PRODUCTION_CONFIG = {
new CssMinimizerPlugin(),
],
},
plugins: htmlWebpackPlugins,
};
module.exports = merge(BASE_CONFIG, PRODUCTION_CONFIG);