This repository has been archived by the owner on Dec 1, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathwebpack.config.js
124 lines (120 loc) · 3.51 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
/* eslint-env node */
var path = require('path'),
extractTextPlugin = require('extract-text-webpack-plugin'),
webpack = require('webpack');
var config = {
entry: {
main: ['babel-polyfill', './src/MusicFestival.Vue.Template/Assets/Scripts/main.js', './src/MusicFestival.Vue.Template/Assets/Styles/Main.less']
},
output: {
path: path.resolve(__dirname, './src/MusicFestival.Vue.Template/Assets/bundled/'),
publicPath: '/src/MusicFestival.Vue.Template/Assets/bundled/',
filename: '[name].bundle.js'
},
plugins: [
new extractTextPlugin('[name].bundle.css'), // save the css as external files instead of bundling them into the javascripts
new webpack.WatchIgnorePlugin([/node_modules/]), // turn off watcher for node_modules and our vueImports.js file created above
],
resolve: {
alias: {
vue: 'vue/dist/vue.js',
'@': path.join(__dirname, 'src/MusicFestival.Vue.Template/Assets')
}
},
module: {
loaders: [{
test: /\.less$/,
use: extractTextPlugin.extract({
use: [
{
loader: 'css-loader',
options: {
// If you are having trouble with urls not resolving add this setting.
// See https://github.com/webpack-contrib/css-loader#url
url: false
}
},
{
loader: 'postcss-loader'
},
{
loader: 'less-loader'
}
]
})
},
{
test: /\.js$/,
exclude: [/node_modules/],
use: [{
loader: 'babel-loader'
}]
},
{
test: /\.vue$/,
exclude: [/node_modules/],
loader: 'vue-loader'
},
{
test: /\.svg$/,
exclude: /node_modules/,
use: [
{ loader: 'svg-sprite-loader' }
]
},
{
test: /\.(png|jpe?g|gif)(\?.*)?$/,
loader: 'url-loader',
exclude: /node_modules/,
options: {
limit: 10000
}
},
{
test: /\.(js|vue)$/,
exclude: /node_modules/,
loader: 'eslint-loader',
options: {
configFile: '.eslintrc.js'
}
}
]
},
stats: {
children: false,
colors: true
},
devtool: 'source-map',
watchOptions: {
}
};
if (process.env.NODE_ENV === 'production') {
// stuff that should only happen when doing a production build
config.plugins.push(new webpack.optimize.UglifyJsPlugin({
parallel: {
cache: true,
workers: 2
},
sourceMap: true,
mangle: true,
compress: {
warnings: false,
pure_getters: true,
unsafe: true,
unsafe_comps: false, // breaks some minification, so turned off!
screw_ie8: true,
sequences: true,
dead_code: true,
conditionals: true,
booleans: true,
unused: true,
if_return: true,
join_vars: true,
drop_console: true
},
output: {
comments: false
}
}));
}
module.exports = config;