-
-
Notifications
You must be signed in to change notification settings - Fork 4
/
webpack.config.js
48 lines (47 loc) · 1.06 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
const path = require('path');
const BabelMinifyPlugin = require('babel-minify-webpack-plugin');
const {DefinePlugin} = require('webpack');
module.exports = (env = {}, argv = {}) => ({
entry: './lib/index.js',
mode: argv.mode || 'development',
output: {
path: __dirname,
filename: argv.mode === 'production' ? 'index.min.js' : 'index.js',
},
devtool: argv.mode === 'production' ? 'source-map' : 'cheap-module-eval-source-map',
module: {
rules: [{
test: /\.jsx?$/,
loader: 'babel-loader',
exclude: /node_modules/,
}, {
test: /\.js$/,
include: [
path.resolve(__dirname, 'node_modules/react-hammerjs'),
],
use: [{
loader: 'babel-loader',
options: {
plugins: [
'@babel/plugin-proposal-class-properties',
],
babelrc: false,
},
}],
}],
},
plugins: [
new DefinePlugin({
'process.env': {
NODE_ENV: JSON.stringify(argv.mode),
},
}),
...(argv.mode === 'production' ? [new BabelMinifyPlugin()] : []),
],
devServer: {
watchContentBase: true,
},
resolve: {
mainFields: ['browser', 'main'],
},
});