forked from Pomax/BezierInfo-2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
99 lines (86 loc) · 2.24 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
var webpack = require('webpack');
var path = require('path');
var fs = require('fs');
// see http://jlongster.com/Backend-Apps-with-Webpack--Part-I
var externals = false;
// Bundle entry point
var entry = ['./components/App.jsx'];
// Bundle target
var target = "web";
// Bundle output
var output = {
path: __dirname,
filename: 'article.js'
};
// Necessary webpack loaders for converting our content:
var webpackLoaders = [
'babel-loader',
'eslint',
__dirname + '/lib/latex-loader',
__dirname + '/lib/pre-loader',
__dirname + '/lib/p-loader'
];
var plugins = [];
// Dev mode: make certain concessions to speed up dev work.
if(process.argv.indexOf("--prod") === -1 && process.argv.indexOf("--lint")) {
// use the webpack hot Reload server:
entry.push('webpack/hot/dev-server');
// allow code in textareas when in dev mode:
webpackLoaders.push(__dirname + '/lib/textarea-loader');
}
// Prod mode: make sure to minify the bundle
else if(process.argv.indexOf("--prod") > -1) {
plugins.push(new webpack.optimize.UglifyJsPlugin());
}
// However, do we want one full page, or single pages with react-router?
if(process.argv.indexOf("--singles") !== -1 ) {
entry = ['./lib/site/routemap.js'];
target = "node";
output = {
path: output.path + '/pages',
filename: "routemap.js",
library: "routemap",
libraryTarget: "commonjs2"
};
console.log("\n","marking node_modules as external","\n");
externals = {};
fs.readdirSync('node_modules')
.filter(function(x) { return ['.bin'].indexOf(x) === -1; })
.forEach(function(mod) { externals[mod] = 'commonjs ' + mod; });
plugins.pop();
}
// And the final config that webpack will read in.
module.exports = {
entry: entry,
target: target,
output: output,
module: {
loaders: [
{
test: /\.(png|gif)$/,
loader: "file?name=images/packed/[hash].[ext]"
},
{
test: /\.less$/,
loader: "style!css!less"
},
{
test: /\.json$/,
loader: "json"
},
{
test: /.jsx?$/,
include: [
/components/,
/lib.site/
],
loaders: webpackLoaders
}
]
},
plugins: plugins,
eslint: {
configFile: __dirname + '/.eslintrc'
},
externals: externals
};