-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathwebpack.config.js
More file actions
120 lines (113 loc) · 2.95 KB
/
webpack.config.js
File metadata and controls
120 lines (113 loc) · 2.95 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
119
120
const path = require('path');
const webpack = require('webpack');
const JSDocWebpackPlugin = require('@toanzzz/jsdoc-webpack-plugin');
const { InjectorWebpackConfig } = require('@bitchcraft/injector');
const TerserPlugin = require('terser-webpack-plugin');
const jsdocConfig = require('./jsdoc.json');
const config = {
context: path.resolve(__dirname),
entry: {
app: [
'./client/index.js',
],
},
output: {
path: path.join(__dirname, 'build'),
filename: 'bundle.js',
chunkFilename: 'bundle.js',
publicPath: '/static/'
},
plugins: [
new webpack.NoEmitOnErrorsPlugin(),
new webpack.IgnorePlugin(/jsdom$/),
new webpack.DefinePlugin({
"process.env": {
NODE_ENV: JSON.stringify(process.env.NODE_ENV),
API_ENDPOINT: JSON.stringify(process.env.API_ENDPOINT),
}
}),
new webpack.LoaderOptionsPlugin({
options: {
handlebarsLoader: {}
},
}),
],
module: {
rules: [
{
test: /\.(js|jsx)?$/,
exclude: /node_modules/,
use: [
{
loader: 'thread-loader',
options: {
workers: 4,
workerParallelJobs: 50,
workerNodeArgs: ['--max-old-space-size=4096'],
poolTimeout: 2000,
poolParallelJobs: 50,
name: "threadloaderpool"
}
}, {
loader: 'babel-loader',
query: {
cacheDirectory: true,
babelrc: true,
plugins: [],
},
}, 'react-hot-loader/webpack'],
}, {
test: /\.(ttf|eot|svg|woff(2))(\?v=[0-9]\.[0-9]\.[0-9])?$/,
use: [
{
loader: 'thread-loader',
options: {
workers: 4,
workerParallelJobs: 50,
workerNodeArgs: ['--max-old-space-size=4096'],
poolTimeout: 2000,
poolParallelJobs: 50,
name: "threadloaderpool"
}
}, 'cache-loader', 'url-loader?limit=50000']
}, {
test: /\.(otf|eot|png|svg|ttf|woff|woff2)(\?v=[0-9]\.[0-9]\.[0-9])?$/,
use: [
{
loader: 'thread-loader',
options: {
workers: 4,
workerParallelJobs: 50,
workerNodeArgs: ['--max-old-space-size=4096'],
poolTimeout: 2000,
poolParallelJobs: 50,
name: "threadloaderpool"
}
}, 'cache-loader', 'url-loader?limit=8192']
}
].concat(InjectorWebpackConfig.rules),
},
resolve: {
alias: { 'react-dom': '@hot-loader/react-dom' },
extensions: [ '.js', '.jsx', '.json' ],
},
resolveLoader: {
modules: [ 'node_modules', InjectorWebpackConfig.resolveLoader.modules[0] ],
},
}
config.mode = process.env.NODE_ENV;
if (process.env.NODE_ENV === 'development') {
config.devtool = 'cheap-module-eval-source-map';//'inline-source-map';
config.plugins.unshift(new webpack.HotModuleReplacementPlugin());
config.entry['app'].unshift('eventsource-polyfill', 'webpack-hot-middleware/client');
// on-the-fly jsdoc builds
config.plugins.push(
new JSDocWebpackPlugin(jsdocConfig)
);
} else if (process.env.NODE_ENV === 'production') {
// uglify
config.optimization = {
minimizer: [ new TerserPlugin({ cache: true }) ]
};
}
module.exports = config;