-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.config.js
More file actions
105 lines (100 loc) · 2.66 KB
/
webpack.config.js
File metadata and controls
105 lines (100 loc) · 2.66 KB
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
96
97
98
99
100
101
102
103
104
105
var path = require('path');
var webpack = require('webpack');
var HtmlWebpackPlugin = require('html-webpack-plugin');
// path
var ROOT_PATH = path.resolve(__dirname);
var SRC_PATH = path.resolve(ROOT_PATH, 'src');
var BUILD_PATH = path.resolve(ROOT_PATH, 'dist');
// banner info
var pkg = require('./package.json');
var banner = pkg.name + " " + pkg.version +
"\n" + new Date().toLocaleDateString() + " " + pkg.author +
"\n" + pkg.homepage;
module.exports = {
entry: {
app: path.resolve(SRC_PATH, 'main.js'),
vendors: ['vue', 'es6-promise']
},
output: {
path: BUILD_PATH,
publicPath: '/dist',
filename: '[name].js',
chunkFilename: '[chunkhash:8].js'
},
module: {
loaders: [{
test: /\.vue$/,
loader: 'vue'
}, {
test: /\.js$/,
exclude: /node_modules/,
loader: 'babel'
}, {
test: /\.less$/,
exclude: /node_modules/,
loader: 'less'
}, {
test: /\.html$/,
loader: 'html'
}, {
test: /\.css$/,
loader: "style-loader!css-loader"
}, {
test: /\.(png|jpg|jpeg)$/,
loader: 'url?limit=5120'
}, {
test: /\.(gif|svg|woff|woff2|ttf|eot|otf)$/,
loader: 'file'
}
]
},
plugins: [
new HtmlWebpackPlugin({
title: 'UnKnown Me',
template: path.resolve(SRC_PATH, 'index.html'),
filename: '../index.html'
})
],
vue: {
autoprefixer: {
browsers: ['> 1%']
},
loaders: {
css: 'vue-style!css',
less: 'vue-style!css!less'
}
},
babel: {
presets: ["es2015", "stage-2"],
plugins: ["transform-runtime"],
comments: false
},
devServer: {
historyApiFallback: true,
noInfo: true,
stats: { colors: true },
host: '0.0.0.0'
},
devtool: 'eval-source-map'
}
if (process.env.NODE_ENV === 'production') {
delete module.exports.devtool;
module.exports.plugins = (module.exports.plugins || []).concat([
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: '"production"'
}
}),
new webpack.optimize.UglifyJsPlugin({
compress: {
warnings: false
},
output: {
comments: false
}
}),
new webpack.optimize.OccurenceOrderPlugin(),
new webpack.optimize.CommonsChunkPlugin('vendors', 'vendors.js'),
new webpack.BannerPlugin(banner)
])
}