forked from webgme/user-management-page
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
83 lines (72 loc) · 2.64 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
/**
* @author kecso / https://github.com/kecso
* @author pmeijer / https://github.com/pmeijer
*/
var webpack = require('webpack'),
path = require('path'),
SRC_DIR = path.join(__dirname, 'src/client'),
DIST_DIR = path.join(__dirname, 'dist'),
isProduction = process.env.NODE_ENV ? process.env.NODE_ENV !== 'development' : true;
console.log('Production build mode:', isProduction);
if (isProduction) {
process.env['NODE_ENV'] = 'production';
}
/**
* Conditionally loads plugins (mainly for production build)
* @return {Array} - Array of plugins
*/
function getPlugins() {
var plugins = [];
// Always expose NODE_ENV to webpack, you can now use `process.env.NODE_ENV`
// inside your code for any environment checks; UglifyJS will automatically
// drop any unreachable code.
plugins.push(new webpack.DefinePlugin({
"process.env": {
NODE_ENV: JSON.stringify(process.env.NODE_ENV)
}
}));
plugins.push(new webpack.ProvidePlugin({
$: "jquery",
jQuery: "jquery"
}));
// Conditionally add plugins for Production builds.
if (isProduction) {
plugins.push(new webpack.optimize.UglifyJsPlugin({minimize: true}));
} else { // Development plugins
// ...
}
return plugins;
}
module.exports = {
devtool: 'source-map',
entry: {
main: path.join(SRC_DIR, 'main.jsx'),
login: path.join(SRC_DIR, 'login.jsx')
},
output: {
path: DIST_DIR,
filename: '[name].js',
publicPath: ''
},
module: {
loaders: [
{test: /^((?!config).)*\.(js|jsx)$/, exclude: path.join(__dirname, 'node_modules'), loader: 'babel-loader'},
{test: /\.css$/, loader: 'style-loader!css-loader'},
{test: /\.(jpg|png)$/, loader: 'file-loader'},
// **IMPORTANT** This is needed so that each bootstrap js file required by
// bootstrap-webpack has access to the jQuery object
{test: /bootstrap\/js\//, loader: 'imports-loader?jQuery=jquery'},
// Loader for react-select's less stylesheet
{test: /\.less$/, loader: 'style-loader!css-loader!less-loader'},
// Needed for the css-loader when [bootstrap-webpack](https://github.com/bline/bootstrap-webpack)
// loads bootstrap's css.
// Configure font-awesome loaders
{test: /\.woff(2)?(\?v=\d\.\d\.\d)?$/, loader: "url-loader?limit=10000&mimetype=application/font-woff"},
{test: /\.(ttf|eot|svg)(\?v=\d\.\d\.\d)?$/, loader: "file-loader"}
]
},
plugins: getPlugins(),
resolve: {
extensions: ['.js', '.jsx']
}
};