-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwebpack.config.js
154 lines (149 loc) · 3.29 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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
/**
* Copyright (c) 2018 Aleksej Komarov
* SPDX-License-Identifier: GPL-2.0-or-later
*/
'use strict';
const webpack = require('webpack');
const path = require('path');
const BuildNotifierPlugin = require('webpack-build-notifier');
const { NODE_ENV, RECAPTCHA_SITE_KEY } = require('warsow-common/config');
const config = {
mode: 'none',
entry: {
client: [
'./packages/warsow-web-client',
],
},
output: {
path: path.resolve(__dirname, 'public/bundles'),
publicPath: '/bundles/',
filename: '[name].bundle.js',
},
resolve: {
extensions: ['.mjs', '.js', '.jsx'],
},
module: {
rules: [
{
test: /\.m?jsx?$/,
exclude: /node_modules/,
use: [
{
loader: 'babel-loader',
options: {
presets: [
['@babel/preset-env', {
modules: false,
useBuiltIns: 'usage',
}],
'@babel/preset-react',
],
plugins: [
['@babel/plugin-proposal-decorators', {
legacy: true,
}],
'@babel/plugin-proposal-class-properties',
],
},
},
],
},
{
test: /\.scss$/,
use: [
'style-loader',
'css-loader',
'sass-loader',
],
},
{
test: /\.css$/,
use: [
'style-loader',
'css-loader',
],
},
{
test: /\.(png|jpg|gif|ico)$/,
use: [
{
loader: 'file-loader',
options: {
name: 'images/[name].[ext]',
},
},
],
},
{
test: /\.(ttf|woff|woff2|eot|svg)$/,
use: [
{
loader: 'file-loader',
options: {
name: 'fonts/[name].[ext]',
},
},
],
},
],
},
plugins: [
new BuildNotifierPlugin(),
new webpack.DefinePlugin({
'process.env': JSON.stringify({
NODE_ENV,
RECAPTCHA_SITE_KEY,
}),
}),
],
devtool: 'source-map',
devServer: {
// Mandatory settings
port: 3000,
publicPath: '/bundles/',
contentBase: 'public',
historyApiFallback: {
index: '/index.html',
},
// Informational flags
progress: false,
quiet: false,
noInfo: false,
// Fine-grained logging control
stats: {
assets: false,
builtAt: false,
cached: false,
children: false,
chunks: false,
colors: true,
hash: false,
timings: false,
version: false,
modules: false,
},
},
};
// Add optimization plugins when generating the final bundle
if (NODE_ENV === 'production') {
const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
config.devtool = false;
config.plugins = config.plugins.concat([
new webpack.optimize.OccurrenceOrderPlugin(),
new UglifyJsPlugin({
parallel: false,
uglifyOptions: {
parse: {},
compress: {
inline: false, // Workaround, see: https://github.com/mishoo/UglifyJS2/issues/2842
passes: 2,
},
output: {
beautify: false,
comments: false,
},
},
}),
]);
}
module.exports = config;