-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
134 lines (115 loc) · 2.74 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
129
130
131
132
133
134
var webpack = require('webpack');
var HtmlWebpackPlugin = require('html-webpack-plugin');
var ExtractTextPlugin = require("extract-text-webpack-plugin");
var path = require('path');
module.exports = function (options) {
var PATHS = {
app: __dirname + '/app',
build: __dirname + '/build',
bower: __dirname + '/bower_components'
};
var postLoaders = [];
var preLoaders = [{
test: /\.js$/,
exclude: [/libs/, /node_modules/],
loader: 'jscs-loader'
}];
var loaders = [{
test: /\.js$/,
loader: 'ng-annotate!babel!jshint',
exclude: [/libs/, /node_modules/]
}, {
test: /\.json$/,
loader: 'json-loader'
}, {
test: /\.html$/,
loader: 'raw',
exclude: /node_modules/
}, {
test: /\.css$/,
loader: 'style!css'
}, {
test: /\.(otf|eot|png|svg|jpg|ttf|woff|woff2)(\?v=[0-9]\.[0-9]\.[0-9])?$/,
loader: 'url-loader?limit=10000'
},
];
if (process.env.NODE_ENV === 'production') {
PATHS.build = __dirname + '/dist';
}
var plugins = [
new webpack.DefinePlugin({
ON_TEST: process.env.NODE_ENV === 'test',
ON_DEV: process.env.NODE_ENV === 'dev',
ON_PROD: process.env.NODE_ENV === 'production'
}),
new HtmlWebpackPlugin({
inject: true,
extraFiles: 'app/images/logo-2015.svg',
template: 'app/index.html',
favicon: 'app/favicons/favicon.ico',
minify: {
removeAttributeQuotes: true
}
})
];
if (options.test) {
postLoaders.push({
test: /\.js$/,
exclude: /node_modules/,
loader: 'istanbul-instrumenter'
});
}
if (options.separateStylesheet) {
plugins.push(new ExtractTextPlugin("main.css" + (options.longTermCaching ?
"?[contenthash]" : "")));
loaders.push({
test: /\.scss$/,
loader: ExtractTextPlugin.extract('css!sass')
});
}
if (!options.separateStylesheet) {
loaders.push({
test: /\.scss$/,
loader: 'style!css!sass'
})
}
if (options.minimize) {
plugins.push(
new webpack.optimize.UglifyJsPlugin({
compressor: {
warnings: false
}
}),
new webpack.optimize.DedupePlugin(),
new webpack.NoErrorsPlugin()
);
}
return {
devtool: options.devtool,
debug: options.debug,
context: PATHS.app,
entry: {
index: './index.js'
},
output: {
path: PATHS.build,
filename: "bundle.js",
publicPath: ""
},
resolve: {
modulesDirectories: ['node_modules']
},
plugins: plugins,
devServer: {
stats: {
cached: false,
exclude: [/node_modules/]
}
},
module: {
loaders: loaders,
preLoaders: preLoaders,
postLoaders: postLoaders
}
}
}