-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
89 lines (85 loc) · 2.17 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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
var path = require('path');
var webpack = require('webpack');
var isProd = process.env.NODE_ENV === 'production';
var loadRules = require('./loadRules');
var ExtractTextPlugin = require('extract-text-webpack-plugin');
var CleanWebpackPlugin = require('clean-webpack-plugin');
var DOMO_PATH = './example';
var LID_PATH = './lib';
var publicPath = '/';
var config = {
entry: {
"index": ['./example/app.js']
},
module: {
rules: loadRules,
noParse: [/\.min\.js$/]
},
output: {
path: path.join(__dirname, DOMO_PATH),
filename: '[name].js',
// publicPath: publicPath,
chunkFilename: '[name].[chunkhash].js',
libraryTarget: 'umd'
},
plugins: [
new ExtractTextPlugin({
filename: '[name].css',
disable: false,
allChunks: true
})
],
target: "web",
devServer: {
contentBase: DOMO_PATH,
historyApiFallback: true,
hot: true,
port: 8080,
publicPath: publicPath,
noInfo: false,
stats: {
assets: true,
children: false,
chunks: false,
hash: false,
modules: false,
publicPath: false,
timings: true,
version: false,
warnings: true,
colors: {
green: '\u001b[32m',
}
},
}
};
if(isProd) {
//use gulp instead
// config.entry = {
// "index": ['./src/index.js']
// }
// config.output.path = path.join(__dirname, LID_PATH);
// config.plugins.push(
// new CleanWebpackPlugin(
// ['lib'],
// {
// root: path.join(__dirname),
// verbose: true,
// dry: false
// }
// )
// )
} else {
config.plugins.push(
new webpack.HotModuleReplacementPlugin(),
new CleanWebpackPlugin(
['index.css','index.js'],
{
root: path.join(__dirname, DOMO_PATH), //根目录
verbose: true, //开启在控制台输出信息
dry: false //启用删除文件
}
)
)
}
module.exports = config;