-
Notifications
You must be signed in to change notification settings - Fork 2
/
webpack.config.js
79 lines (70 loc) · 1.54 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
var webpack = require('webpack');
var HtmlWebpackPlugin = require('html-webpack-plugin');
var ExtractTextPlugin = require('extract-text-webpack-plugin');
var isPro = process.env.npm_lifecycle_event == 'build'
var config = {
entry: {
app: './src/index',
vendors:['echarts','rxjs']
},
output: {
path: __dirname + '/docs',
filename: '[name].[hash].js',
//publicPath: isPro ? '/react-demo/' : ''
},
resolve: {
modulesDirectories: ['node_modules', './'],
alias: {
'npm': __dirname + '/node_modules'
},
extensions: ['', '.js', '.html', '.css', '.jsx']
},
devtool: isPro ? '/rxjs-sort-visualization' : 'eval-source-map',
module: {
loaders: [
{
test: /\.js$/,
loaders: ['babel'],
exclude: /node_modules/
},
{
test: /\.less$/,
loader: ExtractTextPlugin.extract(
'style-loader',
'css-loader?sourceMap!less?sourceMap'
)
}, {
test: /\.css/,
loader: ExtractTextPlugin.extract(
'style-loader',
'css-loader?sourceMap'
)
}, {
test: /\.(png|jpg|jpeg|gif|svg|woff|woff2|ttf|eot)$/,
loader: 'file'
}
],
},
plugins: [
new webpack.optimize.CommonsChunkPlugin('vendors', 'vendors.js'),
new ExtractTextPlugin('[name].[hash].css'),
new HtmlWebpackPlugin({
template: 'src/index.html',
inject: true
}),
],
devServer: {
historyApiFallback:true,
port: 7777,
}
}
if (isPro) {
config.plugins.unshift(new webpack.optimize.UglifyJsPlugin({
compress: {
warnings: false,
drop_debugger: true,
drop_console: true
}
}))
}
module.exports = config