mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2025-10-30 02:39:05 +08:00
Refactor webpack configs (#3170)
* Refactor webpack configs * Remove unused import
This commit is contained in:
parent
df2a9e7f01
commit
6668575cea
3 changed files with 15 additions and 35 deletions
|
|
@ -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",
|
||||
}),
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue