-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
63 lines (61 loc) · 1.73 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
55
56
57
58
59
60
61
62
63
/**
* Created by cleverzhang on 2018/2/28.
*/
const path = require('path');
const root = __dirname;
const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin'); //installed via npm
const CleanWebpackPlugin = require('clean-webpack-plugin');
const {ReactLoadablePlugin} = require('react-loadable/webpack');
module.exports = {
bail: true,
entry: {
/*'webpack-dev-server/client',*/
main: path.resolve(root, 'src/main.js')
},
output: {
path: path.resolve(root, 'dist')
},
/*externals:{
Zepto:'Zepto'
},*/
optimization: {
runtimeChunk: true,
splitChunks: {
chunks: 'all'
}
/*cacheGroups: {
styles: {
name: 'style',
test: /\.css$/,
chunks: 'all',
enforce: true
}
}*/
},
module: {
rules: [
{test: /\.jsx?$/, use: 'babel-loader', exclude: /node_modules/},
{test: /\.css$/, use: ['style-loader', 'css-loader']},
{
test: /\.(png|jpg|gif)$/,
use: 'url-loader?limit=30720&name=images/[name].[ext]?[hash:8]',
exclude: path.resolve(root, 'src/images/normal')
},
{
test: /\.(png|jpg|gif)$/,
use: 'file-loader?name=images/normal/[name].[ext]?[hash:8]',
include: path.resolve(root, 'src/images/normal')
}
]
},
plugins: [
new CleanWebpackPlugin(['dist']),
new HtmlWebpackPlugin({
template: 'index.html'
}),
new ReactLoadablePlugin({
filename: './dist/react-loadable.json'
})
]
};