forked from TheLarkInn/angular-starter-es6-webpack
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
82 lines (73 loc) · 2.38 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
var webpack = require('webpack');
var nodeEnvironment = process.env.NODE_ENV
var bourbon = require('node-bourbon').includePaths;
var _ = require('lodash');
var config = {
context: __dirname + '/app',
entry: './index.js',
plugins: [
new webpack.HotModuleReplacementPlugin(),
new webpack.DefinePlugin({
'INCLUDE_ALL_MODULES': function includeAllModulesGlobalFn(modulesArray, application) {
modulesArray.forEach(function executeModuleIncludesFn(moduleFn) {
moduleFn(application);
});
},
ENVIRONMENT: JSON.stringify(nodeEnvironment)
})
],
output: {
path: __dirname + '/app',
filename: 'bundle.js'
},
resolve: {
root: __dirname + '/app'
},
jscs: {
// JSCS errors are displayed by default as warnings.
// Set `emitErrors` to `true` to display them as errors.
emitErrors: false,
// JSCS errors do not interrupt the compilation.
// Set `failOnHint` to `true` if you want any file with
// JSCS errors to fail.
failOnHint: false
},
module: {
preLoaders: [{
test: /\.js$/,
exclude: /node_modules/,
loader: 'jscs-loader'
}],
loaders: [
{test: /\.js$/, exclude: /(node_modules)/, loader: 'babel'},
{test: /\.html/, exclude: /(node_modules)/, loader: 'html-loader'},
{test: /\.s?css$/, loader: 'style!css!sass?includePaths[]=' + bourbon },
{test: /\.(png|jpg)$/, loader: 'url-loader?mimetype=image/png'}
]
}
}
switch (nodeEnvironment) {
case 'production':
config.output.path = __dirname + '/dist';
config.plugins.push(new webpack.optimize.UglifyJsPlugin());
config.plugins.push(new webpack.optimize.DedupePlugin());
config.plugins.push(new webpack.optimize.OccurenceOrderPlugin());
config.plugins.push(new webpack.optimize.CommonsChunkPlugin({name: 'vendor', minChunks: Infinity}));
config.output.filename = '[name].js';
config.entry = {
bundle: './index.js',
vendor: ['angular', 'angular-ui-router', 'lodash']
}
config.devtool = 'source-map';
break;
case 'test':
config.entry = './index.js';
break;
case 'development':
config.entry = ['./index.js', 'webpack/hot/dev-server'];
config.devtool = 'source-map';
break;
default:
console.warn('Unknown or Undefigned Node Environment. Please refer to package.json for available build commands.');
}
module.exports = config;