-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.node.config.js
113 lines (89 loc) · 3.17 KB
/
webpack.node.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
'use strict';
var webpack = require('webpack');
var path = require('path');
var ngAnnotatePlugin = require('ng-annotate-webpack-plugin');
webpack.cache = true;
// PATHS
var PATHS = {
app: __dirname + '/public',
bootstrapFonts: path.resolve(__dirname, "./public/bower_components/bootstrap-sass/assets/fonts/bootstrap"),
sassFiles: path.resolve(__dirname, "./public/css/"),
bowerRoot: path.resolve(__dirname, "./public/bower_components")
};
var config = {};
config.devtool = 'source-map';
config.context = PATHS.app;
config.entry = {
app: ['./js/bootstrapApp.js']
};
config.output = {
path: PATHS.app,
filename: 'bundle.js'
}
config.resolve = {
alias: {}
}
config.addVendor = function (name, path) {
this.resolve.alias[name] = path;
this.module.noParse.push(new RegExp('^' + name + '$'));
}
var autoprefixer = require('autoprefixer-core');
var csswring = require('csswring');
config.module = {
loaders: [
{ test: /\.woff(\?v=\d+\.\d+\.\d+)?$/,
loader: "url?limit=10000&minetype=application/font-woff",
include: PATHS.bootstrapFonts
},
{ test: /\.woff2(\?v=\d+\.\d+\.\d+)?$/,
loader: "url?limit=10000&minetype=application/font-woff",
include: PATHS.bootstrapFonts
},
{ test: /\.ttf(\?v=\d+\.\d+\.\d+)?$/,
loader: "url?limit=10000&minetype=application/octet-stream",
include: PATHS.bootstrapFonts
},
{ test: /\.eot(\?v=\d+\.\d+\.\d+)?$/,
loader: "file-loader",
include: PATHS.bootstrapFonts
},
{ test: /\.svg(\?v=\d+\.\d+\.\d+)?$/,
loader: "url?limit=10000&minetype=image/svg+xml",
include: PATHS.bootstrapFonts
},
{
test: /\.scss$/,
loader: "style-loader!css-loader!postcss-loader!sass?indentedSyntax",
include: PATHS.sassFiles
}
],
plugins: [
new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/),
new ngAnnotatePlugin({
add: true
}),
new webpack.optimize.UglifyJsPlugin({
mangle: {
except: ['$super', '$', 'exports', 'require']
}
})
],
noParse: []
}
config.postcss = function () {
return [autoprefixer, csswring];
}
/*
These need to be required by their aliases in ./public/js/vendor.js
*/
config.addVendor("angular", PATHS.bowerRoot + "/angular/angular.js");
config.addVendor("ui-router", PATHS.bowerRoot + "/ui-router/release/angular-ui-router.js");
config.addVendor("moment", PATHS.bowerRoot + "/moment/moment.js");
config.addVendor("jquery", PATHS.bowerRoot + "/jquery/dist/jquery.js");
config.addVendor("chance", PATHS.bowerRoot + "/chance/chance.js");
config.addVendor("lodash", PATHS.bowerRoot + "/lodash/lodash.js");
config.addVendor("ui-bootstrap", PATHS.bowerRoot + "/angular-bootstrap/ui-bootstrap.js");
config.addVendor("ngAnimate", PATHS.bowerRoot + "/angular-animate/angular-animate.js");
config.addVendor("ui-mask", PATHS.bowerRoot + "/angular-ui-mask/dist/mask.js");
config.addVendor("Chart.js", PATHS.bowerRoot + "/Chart.js/Chart.js");
module.exports = config;