-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
128 lines (124 loc) · 3.34 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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
var webpack = require('webpack')
var path = require('path');
var HtmlWebpackPlugin = require('html-webpack-plugin')
var ExtractTextPlugin = require('extract-text-webpack-plugin')
var srcPath = path.join(__dirname, 'src');
var config = {
entry: {
main:['./src/main.js']
},
output: {
path: path.resolve(__dirname, 'static/'),
publicPath: '',
filename: '[name].js'
},
resolve: {
alias: {
jquery: path.join(__dirname, './node_modules/jquery'),
mediaelement: path.join(__dirname, './node_modules/mediaelement'),
moxie: path.join(__dirname, 'plupload/js/moxie.js'),
plupload: path.join(__dirname, 'plupload/js/plupload.dev.js')
}
},
module: {
// avoid webpack trying to shim process
noParse: /es6-promise\.js$/,
loaders: [
{
test: /\.vue$/,
loader: 'vue'
},
{
test: /\.js$/,
// excluding some local linked packages.
// for normal use cases only node_modules is needed.
exclude: /node_modules|vue\/dist|vue-router\/|vue-loader\/|vue-hot-reload-api\/|plupload/,
loader: 'babel'
},
{ test: /\.css$/,
loader: "style-loader!css-loader"
},
{
test: /\.(png|jpg|gif)$/,
loader: 'url-loader?limit=8190'
},
{
test: /\.(ttf|eot|svg)(\?v=[0-9]\.[0-9]\.[0-9])?$/,
loader: "file-loader"
},
{ test: /\.woff(2)?(\?v=[0-9]\.[0-9]\.[0-9])?$/,
loader: "url-loader?limit=10000&minetype=application/font-woff"
},
{
test: /\.json$/,
loader: 'json-loader'
},
{
test: /plupload\/js\/moxie\.js/,
loader: 'exports?this.mOxie'
}
]
},
babel: {
presets: ['es2015'],
plugins: ['transform-runtime']
},
plugins: [
new webpack.ProvidePlugin({
mOxie: 'moxie'
}),
new webpack.ProvidePlugin({
$: "jquery",
jQuery: "jquery"
}),
new HtmlWebpackPlugin({
filename: 'index.html',
template: 'src/index.html'
})
],
vue: {
loaders: {
js: 'babel'
}
},
debug: true,
displayErrorDetails: true,
outputPathinfo: true
}
if (process.env.NODE_ENV === 'production') {
config.output.publicPath = '//mres.quzhiboapp.com/'
config.output.filename = '[name].[chunkhash].js'
config.output.chunkFilename = '[id].[chunkhash].js'
config.vue.loaders = {
js: 'babel',
css: ExtractTextPlugin.extract('style-loader', 'css-loader'),
less: ExtractTextPlugin.extract('style-loader', 'css-loader!less-loader'),
sass: ExtractTextPlugin.extract('style-loader', 'css-loader!sass-loader'),
stylus: ExtractTextPlugin.extract('style-loader', 'css-loader!stylus-loader')
}
config.plugins = (config.plugins || []).concat([
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: '"production"',
BUILD_TIME: ('"' + new Date().toLocaleString() + '"')
}
}),
new ExtractTextPlugin('[name].[contenthash].css'),
new webpack.optimize.UglifyJsPlugin({
compress: {
warnings: false
}
}),
new webpack.optimize.OccurenceOrderPlugin()
])
} else {
config.plugins = (config.plugins || []).concat([
new webpack.DefinePlugin({
'process.env': {
BUILD_TIME: ('"' + new Date().toLocaleString() + '"')
}
})
])
config.devtool = '#source-map'
}
module.exports = config