-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.config.js
More file actions
105 lines (101 loc) · 2.46 KB
/
Copy pathwebpack.config.js
File metadata and controls
105 lines (101 loc) · 2.46 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 webpack = require('webpack');
var CopyWebpackPlugin = require('copy-webpack-plugin');
var path = require('path');
var merge = require('webpack-merge');
require('es6-promise').polyfill();
var config = require('./config');
var CONFIG = merge(config.base, config[process.env.npm_package_config_branch] || {});
var PATH = './static';
if (process.env.NODE_ENV === 'production') {
PATH = './public';
}
module.exports = {
entry: './src/main.js',
output: {
path: PATH,
publicPath: '/',
filename: 'build.js'
},
// plugins: [
// new CopyWebpackPlugin([
// { from: 'images' }
// ])
// ],
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\//,
loader: 'babel',
query: {
compact: false
}
},
{
test : /\.(ttf|otf|eot|svg|woff(2)?)(\?[a-z0-9]+)?$/,
loader : 'file-loader'
}
]
},
vue: {
loaders: {
scss: 'vue-style!css!sass'
}
},
babel: {
presets: ['es2015'],
plugins: ['transform-runtime']
},
resolve: {
root: path.resolve(__dirname),
alias: {
components: 'src/components',
base: 'src/components/base',
pages: 'src/components/pages',
filters: 'src/filters',
libs: 'src/libs',
models: 'src/models',
services: 'src/services',
styles: 'src/styles',
'rms-models': 'src/models',
'rms-services': 'src/services',
'sbp-components': 'src/sbp/components'
},
extensions: ['', '.js', '.vue', '.scss']
}
}
if (process.env.NODE_ENV === 'production') {
module.exports.plugins = [
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: '"production"'
},
'CONFIG': JSON.stringify(CONFIG)
}),
new webpack.optimize.UglifyJsPlugin({
compress: {
warnings: false
}
}),
new CopyWebpackPlugin([
{from: 'images', to: 'images'},
{from: 'manifest.json', to: 'manifest.json'},
]),
new webpack.optimize.OccurenceOrderPlugin()
]
} else {
module.exports.devtool = '#source-map'
module.exports.plugins = [
new webpack.DefinePlugin({
'CONFIG': JSON.stringify(CONFIG)
})
]
}