This repository has been archived by the owner on Dec 1, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 88
/
make-webpack-config.js
92 lines (83 loc) · 2.4 KB
/
make-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
var path = require('path');
var webpack = require('webpack');
var StatsPlugin = require('stats-webpack-plugin');
var ContextReplacementPlugin = require('webpack/lib/ContextReplacementPlugin');
module.exports = function (options) {
var entry = { index: './src/Index.js' };
var loaders = [
{ test: /\.jsx$/, loader: options.hotComponents ?
[ 'react-hot-loader', 'babel-loader?stage=0' ] : 'babel-loader?stage=0'},
{ test: /\.js$/, loader: 'babel-loader', include: path.join(__dirname, 'src')},
{ test: /\.json$/, loader: 'json-loader' },
{ test: /\.md|markdown$/, loader: 'markdown-loader'}
];
var alias = {};
var aliasLoader = {};
var externals = [
{ 'aws-sdk': 'commonjs aws-sdk' } // This is already available on the lambda server
];
var modulesDirectories = [ 'node_modules', 'web_modules' ];
var extensions = [ '', '.web.js', '.js', '.jsx', '.json' ];
var root = __dirname;
var publicPath = options.devServer ? 'http://localhost:2992/assets/' : '/assets/';
var output = {
path: path.join(__dirname, 'dist'),
publicPath,
filename: '[name].js',
chunkFilename: options.devServer ? '[id].js' : '[name].js',
sourceMapFilename: 'debugging/[file].map',
pathinfo: options.debug,
libraryTarget: 'umd'
};
var excludeFromStats = [
/node_modules[\\\/]react(-router)?[\\\/]/,
/node_modules[\\\/]items-store[\\\/]/
];
var plugins = [
new StatsPlugin(path.join(__dirname, 'build', 'stats.json'), {
chunkModules: true,
exclude: excludeFromStats
}),
new ContextReplacementPlugin(/moment\.js[\/\\]lang$/, /^\.\/(de|pl)$/)
];
if(options.minimize) {
plugins.push(
new webpack.optimize.UglifyJsPlugin({
compressor: {
warnings: false
}
}),
new webpack.optimize.DedupePlugin()
);
plugins.push(
new webpack.DefinePlugin({'process.env': { NODE_ENV: JSON.stringify('production')}}),
new webpack.NoErrorsPlugin()
);
}
return {
entry,
output,
target: 'node',
module: { loaders },
devtool: options.devtool,
debug: options.debug,
resolveLoader: {
root: path.join(__dirname, 'node_modules'),
alias: aliasLoader
},
externals,
resolve: {
root,
modulesDirectories,
extensions,
alias
},
plugins,
devServer: {
stats: {
cached: false,
exclude: excludeFromStats
}
}
};
};