-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathwebpack.config.js
41 lines (34 loc) · 1.07 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
41
const path = require('path');
const webpackMerge = require('webpack-merge');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const CopyWebpackPlugin = require('copy-webpack-plugin')
const StyleLintPlugin = require('stylelint-webpack-plugin');
const modeConfig = env => require(`./build-utils/webpack.${env}`)(env);
const presetConfig = require("./build-utils/loadPresets");
module.exports = ({ mode, presets } = { mode: "production", presets: [] }) => {
console.log(`Building for: ${mode}`);
return webpackMerge(
{
mode,
entry: {
main: path.join(__dirname, './src/index.js'),
vendor: path.join(__dirname, './src/assets/js/vendor.js'),
},
plugins: [
new HtmlWebpackPlugin({
template: 'src/assets/index.html',
inject: 'body',
filename: 'index.html',
}),
new StyleLintPlugin(),
new CopyWebpackPlugin({
patterns: [
{ from: 'src/assets/favicon.ico' }
]
}),
]
},
modeConfig(mode),
presetConfig({ mode, presets }),
)
};