-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
41 lines (36 loc) · 1.08 KB
/
webpack.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// webpack.config.js
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const HtmlInlineScriptPlugin = require('html-inline-script-webpack-plugin');
// Common configuration settings
const mode = "production";
const outputPath = path.resolve(__dirname, "dist");
const commonPlugins = (type, side) => [
new HtmlWebpackPlugin({
template: `./src/${type}/${side}/template.html`,
filename: `${type}_${side}.min.html`,
inject: "body",
minify: {
collapseWhitespace: true,
removeComments: true,
},
}),
new HtmlInlineScriptPlugin(),
];
// Define the different types and sides you have
const cardTypes = ["2d", "3d"];
const cardSides = ["front", "back"];
// Generate configurations for each combination of type and side
const configs = cardTypes.flatMap((type) =>
cardSides.map((side) => ({
entry: `./src/${type}/${side}/index.js`,
output: {
path: outputPath,
filename: `${type}_${side}.bundle.js`,
publicPath: "",
},
plugins: commonPlugins(type, side),
mode,
}))
);
module.exports = configs;