-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
95 lines (92 loc) · 3.14 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
90
91
92
93
94
95
var webpack = require("webpack");
var HtmlwebpackPlugin = require('html-webpack-plugin');
var ExtractTextPlugin = require("extract-text-webpack-plugin");
module.exports = {
entry: {
// app:'./src/js/app.jsx',
// calendar:'./src/js/calendar.jsx',
index:'./src/locator.jsx'
},
output: {
path: './build',
publicPath:"",
filename: 'js/[name].js',
chunkFilename: "js/[chunkhash:8].[name].js"
},
devtool: 'source-map',
//enable dev server
devServer: {
historyApiFallback: true,
hot: true,
host:'0.0.0.0',
inline: true,
progress: true
},
module: {
noParse:[/extlibs/],
loaders: [{
test: /.jsx?$/,
loader: 'babel-loader',
exclude: /node_modules/,
query: {
presets: ['es2015', 'react']
}
}, {
test: /\.html$/,
loader: "html?-minimize"
},{
test: /\.css$/,
loader: ExtractTextPlugin.extract("style-loader", "css-loader")
}, {
test: /\.(jpe?g|png|gif|svg)$/i,
loader: 'url?limit=81920&name=images/[hash:8].[name].[ext]'
}, {
test: /\.(woff|woff2|ttf|eot|svg)(\?v=[0-9]\.[0-9]\.[0-9])?$/,
loader: 'file-loader?name=fonts/[name].[ext]'
}]
},
resolve: {
// root: [path.resolve('./src/js')],
extensions: ['', '.js', '.jsx']
},
externals: {
'react': 'React',
'jquery': '$',
'jQuery': '$'
},
plugins:[
/* new HtmlwebpackPlugin({
title: '搜索页',
filename: '/search.aspx', //生成的html存放路径,相对于 path
template: './src/_layouts.html', //html模板路径
inject: true, //允许插件修改哪些内容,inject: true, 包括head与body inject: head, 只到head
hash: true, //为静态资源生成hash值
chunks: ["app","common"]
}),
new HtmlwebpackPlugin({
title: '工作日',
filename: '/holidays.aspx', //生成的html存放路径,相对于 path
template: './src/_layouts.html', //html模板路径
inject: true, //允许插件修改哪些内容,inject: true, 包括head与body inject: head, 只到head
hash: true, //为静态资源生成hash值
chunks: ["calendar","common"]
}),*/
new HtmlwebpackPlugin({
title: 'SOPS',
filename: '/index.aspx', //生成的html存放路径,相对于 path
template: './src/_layouts.html', //html模板路径
inject: true, //允许插件修改哪些内容,inject: true, 包括head与body inject: head, 只到head
hash: true, //为静态资源生成hash值
chunks: ["index","common"]
}),
new ExtractTextPlugin("css/[name].css", {
publicPath: 'css/',
allChunks: true
}),
new webpack.optimize.CommonsChunkPlugin({
name: ['common'],
filename: "js/[name].js",
minChunks: Infinity
})
]
};