This repository has been archived by the owner on Aug 31, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 171
/
webpack-dev.config.js
79 lines (76 loc) · 1.86 KB
/
webpack-dev.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
const path = require('path');
const webpack = require('webpack');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const resolve = require('path').resolve;
const shelljs = require('shelljs');
const _ = require('lodash');
const pkg = require('./package.json');
const entry = {};
shelljs.ls(resolve(__dirname, 'demos/src')).forEach(demoEntry => {
if (/\.js$/.test(demoEntry)) {
const basename = path.basename(demoEntry, '.js');
const moduleName = _.upperFirst(_.camelCase(basename));
entry[moduleName] = `./demos/src/${demoEntry}`;
}
});
module.exports = {
mode: 'production',
devtool: 'cheap-source-map',
entry,
output: {
filename: substitutions => `${_.lowerFirst(substitutions.chunk.name)}.js`,
library: '[name]',
libraryTarget: 'umd',
path: resolve(__dirname, 'build/')
},
watch: true,
watchOptions: {
aggregateTimeout: 300,
poll: 1000
},
externals: {
'react-dom': 'ReactDOM',
react: 'React'
},
module: {
rules: [
{
test: /\.jsx?$/,
// exclude: /(node_modules|bower_components)/,
use: {
loader: 'babel-loader',
options: {
babelrc: true
}
}
},
{
test: /\.css$/,
use: [
MiniCssExtractPlugin.loader,
'css-loader'
]
},
{
test: /global\.js$/,
use: {
loader: 'string-replace-loader',
options: {
search: '____G6_VERSION____',
replace: pkg.version
}
}
}
]
},
plugins: [
new webpack.NoEmitOnErrorsPlugin(),
new webpack.optimize.AggressiveMergingPlugin(),
new MiniCssExtractPlugin({
// Options similar to the same options in webpackOptions.output
// both options are optional
filename: '[name].css',
chunkFilename: '[id].css'
})
]
};