-
Notifications
You must be signed in to change notification settings - Fork 18
/
webpack.config.js
54 lines (52 loc) · 1.28 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
//使用命令:'npm run build'
var path = require('path');
var webpack = require('webpack');
var ExtractTextPlugin = require('extract-text-webpack-plugin');
module.exports = {
entry: './js/app.js',
//让打包后生成在build.js文件中
output: {
path: './js',
publicPath: './assets',
filename: 'build.js'
},
module: {
loaders: [{
test: /\.vue$/,
loader: 'vue',
options:{}
},
//转化ES6语法
{
test: /\.js$/,
loader: 'babel',
exclude: /node_modules/
},
//图片转化,小于8K自动转化为base64的编码
{
test: /\.(png|jpg|gif)$/,
loader: 'url-loader?name=assets/[name][hash:8].[ext]'
}
]
},
plugins: [
new webpack.BannerPlugin("author: lhq\n" + new Date().toLocaleString()),
new webpack.optimize.UglifyJsPlugin({ //压缩插件
compress: {
warnings: false //不显示警告
}
}),
new webpack.optimize.OccurenceOrderPlugin(),
new ExtractTextPlugin("[name]-[hash].css")
],
resolve: {
alias: {
'vue$': 'vue/dist/vue'
}
},
//这里用于安装babel,如果在根目录下的.babelrc配置了,这里就不写了
babel: {
presets: ['es2015', 'stage-0'],
plugins: ['transform-runtime']
}
}