-
Notifications
You must be signed in to change notification settings - Fork 2
/
webpack.config.js
54 lines (50 loc) · 1.34 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
42
43
44
45
46
47
48
49
50
51
52
53
54
const path = require('path')
const { getIfUtils, removeEmpty } = require('webpack-config-utils')
const { CleanWebpackPlugin } = require('clean-webpack-plugin')
const CopyPlugin = require('copy-webpack-plugin')
module.exports = (env = {}) => {
const { ifProduction, ifNotProduction } = getIfUtils(env)
return {
mode: ifProduction('production', 'development'),
entry: {
index: './src/index.entry.js',
panel: './src/panel.entry.js',
},
output: {
path: path.join(__dirname, 'dist'),
filename: '[name].js',
},
devtool: ifProduction('source-map', false),
module: {
rules: [
{
test: /\.scss$/,
use: [
'style-loader',
'css-loader',
'sass-loader',
],
},
ifNotProduction({
enforce: 'pre',
test: /\.js$/,
exclude: /node_modules/,
use: 'eslint-loader',
}),
{
test: /\.js$/,
exclude: /node_modules/,
use: 'babel-loader',
},
],
},
plugins: removeEmpty([
ifProduction(new CleanWebpackPlugin()),
new CopyPlugin([
{ from: './src/images/**/*', to: 'images', flatten: true },
{ from: './src/manifest.json', flatten: true },
{ from: './src/html/*.html', flatten: true },
]),
]),
}
}