@@ -6,11 +6,9 @@ const path = require("path");
6
6
const paths = require ( "./paths" ) ;
7
7
const webpack = require ( "webpack" ) ;
8
8
9
- const autoprefixer = require ( "autoprefixer" ) ;
10
9
const { CleanWebpackPlugin } = require ( "clean-webpack-plugin" ) ;
11
10
const ForkTsCheckerWebpackPlugin = require ( "fork-ts-checker-webpack-plugin" ) ;
12
11
const HtmlWebPackPlugin = require ( "html-webpack-plugin" ) ;
13
- const TerserPlugin = require ( "terser-webpack-plugin" ) ;
14
12
15
13
const isEnvDevelopment = process . env . NODE_ENV === "development" ;
16
14
const isEnvProduction = process . env . NODE_ENV === "production" ;
@@ -23,11 +21,12 @@ const libId = require("crypto").randomBytes(8).toString("hex");
23
21
module . exports = {
24
22
mode : isEnvProduction ? "production" : "development" ,
25
23
context : paths . projRoot ,
26
- devtool : isEnvProduction ? false : "eval" ,
24
+ devtool : isEnvProduction
25
+ ? false
26
+ : process . env . DEV_TOOL || "inline-source-map" ,
27
27
// Disable perf hints as it's mostly out of the developer's control as we
28
28
// only allow one chunk.
29
29
performance : false ,
30
- stats : "minimal" ,
31
30
resolve : {
32
31
extensions : paths . moduleFileExtensions ,
33
32
alias : {
@@ -46,25 +45,16 @@ module.exports = {
46
45
// Technically this shouldn't be needed as we restrict the library to
47
46
// one chunk, but we set this here just to be extra safe against
48
47
// collisions.
49
- jsonpFunction : libId ,
48
+ chunkLoadingGlobal : libId ,
50
49
libraryTarget : "amd" ,
51
50
// Use "/" in dev so hot updates are requested from server root instead
52
51
// of from "viewer" relative path.
53
52
publicPath : isEnvProduction ? "." : "/" ,
54
53
path : isEnvProduction ? paths . projBuild : undefined ,
55
- // TODO: remove this when upgrading to webpack 5
56
- futureEmitAssets : true ,
57
54
// There will be one main bundle, and one file per asynchronous chunk.
58
55
// In development, it does not produce real files.
59
56
filename : "[name].js" ,
60
57
} ,
61
- optimization : {
62
- // This is only used in production mode
63
- minimizer : [
64
- // Minify JS output
65
- new TerserPlugin ( ) ,
66
- ] ,
67
- } ,
68
58
module : {
69
59
strictExportPresence : true ,
70
60
rules : [
@@ -78,9 +68,6 @@ module.exports = {
78
68
{
79
69
test : / \. ( p n g | j p e ? g | g i f | s v g | e o t | t t f | w o f f | w o f f 2 ) $ / i,
80
70
loader : require . resolve ( "url-loader" ) ,
81
- options : {
82
- esModule : true ,
83
- } ,
84
71
} ,
85
72
// Process application JS with Babel.
86
73
// The preset includes JSX, Flow, TypeScript, and some ESnext features.
@@ -99,9 +86,6 @@ module.exports = {
99
86
use : [
100
87
{
101
88
loader : require . resolve ( "style-loader" ) ,
102
- options : {
103
- esModule : true ,
104
- } ,
105
89
} ,
106
90
{
107
91
loader : require . resolve ( "css-loader" ) ,
@@ -115,20 +99,9 @@ module.exports = {
115
99
// package.json
116
100
loader : require . resolve ( "postcss-loader" ) ,
117
101
options : {
118
- ident : "postcss" ,
119
- plugins : ( ) =>
120
- [
121
- autoprefixer ( {
122
- flexbox : "no-2009" ,
123
- overrideBrowserslist : [
124
- "last 2 chrome versions" ,
125
- "last 2 firefox versions" ,
126
- "last 2 safari versions" ,
127
- ] ,
128
- } ) ,
129
- isEnvProduction &&
130
- require ( "cssnano" ) ( ) ,
131
- ] . filter ( Boolean ) ,
102
+ postcssOptions : {
103
+ plugins : [ "postcss-preset-env" ] ,
104
+ } ,
132
105
} ,
133
106
} ,
134
107
] ,
@@ -165,12 +138,10 @@ module.exports = {
165
138
166
139
isEnvProduction && new CleanWebpackPlugin ( ) ,
167
140
] . filter ( Boolean ) ,
168
- node : {
169
- dgram : "empty" ,
170
- fs : "empty" ,
171
- net : "empty" ,
172
- tls : "empty" ,
173
- // eslint-disable-next-line @typescript-eslint/camelcase
174
- child_process : "empty" ,
141
+ watchOptions : {
142
+ // Don't bother watching node_modules files for changes. This reduces
143
+ // CPU/mem overhead, but means that changes from `npm install` while the
144
+ // dev server is running won't take effect until restarted.
145
+ ignored : / n o d e _ m o d u l e s / ,
175
146
} ,
176
147
} ;
0 commit comments