forked from MuYunyun/yunban
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
52 lines (51 loc) · 1.49 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
var webpack = require('webpack'),
// 使用插件将组件中相同部分抽成一个单独文件
CommonsChunkPlugin = require("webpack/lib/optimize/CommonsChunkPlugin"),
// JS压缩插件
uglifyJsPlugin = webpack.optimize.UglifyJsPlugin,
path = require('path');
module.exports = {
entry: {
'musicBundle': [
'./public/scripts/components/music/music_index' // 引入音乐首页JS脚本
],
'gallery': [
'./public/scripts/components/music/gallery' // 引入音乐广告JS脚本
]
},
output: {
path: path.join(__dirname, '/public/libs/scripts/components/'), // 输出JS路径
publicPath: 'http://localhost:1234/libs/scripts/components/', //服务器上查找路径
filename: '[name].min.js'
},
module: {
loaders: [
{
test: /\.js[x]?$/, // 对ES6和React进行转换
exclude: /node_modules/,
loader: 'babel-loader',
query: {
presets: ['es2015', 'react']
}
},
{ test: /\.(png|jpg)$/, loader: 'url-loader?limit=8192'},
{
test: /\.json$/,
loader:'json-loader'
}
]
},
resolve: {
extensions: ['', '.js', '.jsx'] // 识别文件后缀名
},
plugins: [
// 使用插件将组件中相同部分抽成一个单独文件
new CommonsChunkPlugin('componentInit.min.js', ['musicBundle']),
// JS代码压缩
new uglifyJsPlugin({
compress: {
warnings: false
}
})
]
};