-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathwebpack.config.js
More file actions
118 lines (109 loc) · 2.85 KB
/
webpack.config.js
File metadata and controls
118 lines (109 loc) · 2.85 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
106
107
108
109
110
111
112
113
114
115
116
117
118
var fs = require('fs');
var path = require('path');
var webpack = require('webpack');
var HtmlWebpackPlugin = require('html-webpack-plugin');
var _ = require("underscore");
var jshintConfig = JSON.parse(fs.readFileSync(path.join(__dirname, '.jshintrc')));
var isProduction = (process.env.NODE_ENV === "production");
var webpackConfig = {
context: __dirname,
output: {
path: path.join(__dirname, (isProduction ? "build" : "build-dev")),
// Use a relative `publicPath` to be able to serve from a subdirectory.
publicPath: "static/",
filename: "[name].js?[chunkhash]"
},
entry: {
app: "./src/frontend/index.js",
vendor: [
"jquery",
"underscore",
"node-event-emitter",
"flot",
"flot-plugin-resize",
"flot-plugin-time",
"moment"
]
},
module: {
preLoaders: [
{
test: /\.js$/,
exclude: path.join(__dirname, "node_modules"),
loader: "jshint-loader"
}
],
loaders: [
{
test: /jquery\.(\.min)?\.js$/,
loader: "exports-loader?jQuery.noConflict(true)"
},
{
test: /jquery\.flot(\.min)?\.js$/,
loader: "imports-loader?jQuery=jquery,this=>global!exports-loader?jQuery.plot"
},
{
test: /jquery\.flot(\.[a-z]+)(\.min)?\.js$/,
loader: "imports-loader?jQuery=jquery,this=>global!exports-loader?jQuery.plot"
},
{
test: /\.json$/i,
loader: "json-loader"
},
{
test: /\.less$/i,
loader: "style-loader!css-loader!less-loader"
},
{
test: /\.css$/i,
loader: "style-loader!css-loader"
},
{
test: /\.(jpe?g|png|gif)$/i,
loader: "file-loader?name=[path][name].[ext]?[hash]"
},
{
test: /\.(ttf|woff|eot)$/i,
loader: "file-loader?name=[path][name].[ext]?[hash]"
}
]
},
resolve: {
alias: {
"jquery": path.join(__dirname, "node_modules/jquery/dist/" + (isProduction ? "jquery.min.js" : "jquery.js")),
"flot": path.join(__dirname, "node_modules/Flot/" + ("jquery.flot.js")),
"flot-plugin-resize": path.join(__dirname, "node_modules/Flot/" + ("jquery.flot.resize.js")),
"flot-plugin-time": path.join(__dirname, "node_modules/Flot/" + ("jquery.flot.time.js")),
"prefixer.less": path.join(__dirname, "src/frontend/vendor/prefixer.less"),
"flexbox.less": path.join(__dirname, "src/frontend/vendor/flexbox.less")
},
extensions: ["", ".js"]
},
plugins: [
new webpack.optimize.CommonsChunkPlugin("vendor", "[name].js?[chunkhash]"),
new HtmlWebpackPlugin({
template: './src/frontend/index.blueimp.html'
})
],
jshint: _.extend({
emitErrors: true,
failOnHint: false
}, jshintConfig),
developmentServer: {
port: 3000
}
};
if (isProduction) {
webpackConfig.plugins.push(
new webpack.DefinePlugin({
"process.env": {
NODE_ENV: JSON.stringify("production")
}
}),
new webpack.optimize.DedupePlugin(),
new webpack.optimize.UglifyJsPlugin({
sourceMap: false
})
);
}
module.exports = webpackConfig;