-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathwebpack.config.js
More file actions
86 lines (82 loc) · 2.35 KB
/
webpack.config.js
File metadata and controls
86 lines (82 loc) · 2.35 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
/**
* Created by KimYJ on 2016-12-05.
*/
const path = require('path');
const webpack = require('webpack');
const CommonsChunkPlugin = require("webpack/lib/optimize/CommonsChunkPlugin");
const ExtractTextPlugin = require("extract-text-webpack-plugin");
const webpackMerge = require('webpack-merge');
const devConfig = require('./webpack.dev.config.js');
const target = process.env.npm_lifecycle_event;
const common = {
entry: {
bundle: path.join(__dirname + '/src/main/resources/static/entry/entry.js')
},
output: {
path: path.join(__dirname, '/src/main/resources/static'),
filename: '[name].js'
},
resolve: {
extensions: ['', '.js', '.css'],
alias: {
'styles': __dirname + '/static/styles',
'images': __dirname + '/static/images'
}
},
module: {
/*preLoaders: [
{
test: /\.js$/,
loader: 'eslint',
exclude: /(node_modules|bower_components)/
}
],*/
loaders: [
{
test: /\.js$/,
loader: 'babel',
exclude: /(node_modules|bower_components)/,
query: {
presets: ['es2015']
}
},
{
test: /\.(css|scss)$/,
loader: ExtractTextPlugin.extract({
fallbackLoader: "style-loader",
loader: "css-loader!postcss-loader!sass-loader"
})
},
{
test: /\.(gif|png|jpg)$/,
loader: 'file-loader?name=images/[name].[ext]&mimeType=image/[ext]&limit=100000'
}
]
},
plugins: [
new webpack.optimize.OccurenceOrderPlugin(),
new webpack.NoErrorsPlugin(),
new CommonsChunkPlugin({
name: "commons",
filename: "common.js",
minChunks: Infinity,
})
]
}
const prodConfig = {
plugins: [
new webpack.optimize.UglifyJsPlugin({
compress: {warnings: false}
}),
new ExtractTextPlugin("[name].css")
]
}
var config;
if(target === 'prod') {
console.log('real build');
config = webpackMerge(common, prodConfig);
} else {
console.log('dev build');
config = webpackMerge(common, devConfig);
}
module.exports = config;