@@ -168,6 +168,7 @@ module.exports = function(webpackEnv) {
168
168
// We inferred the "public path" (such as / or /my-project) from homepage.
169
169
// We use "/" in development.
170
170
publicPath : publicPath ,
171
+ globalObject : 'this' ,
171
172
// Point sourcemap entries to original disk location (format as URL on Windows)
172
173
devtoolModuleFilenameTemplate : isEnvProduction
173
174
? info =>
@@ -250,6 +251,9 @@ module.exports = function(webpackEnv) {
250
251
// Keep the runtime chunk separated to enable long term caching
251
252
// https://twitter.com/wSokra/status/969679223278505985
252
253
runtimeChunk : true ,
254
+ // Should set back to true when this issue fixed
255
+ // https://github.com/webpack-contrib/worker-loader/issues/176
256
+ noEmitOnErrors : false ,
253
257
} ,
254
258
resolve : {
255
259
// This allows you to set a fallback for where Webpack should look for modules.
@@ -338,6 +342,63 @@ module.exports = function(webpackEnv) {
338
342
name : 'static/media/[name].[hash:8].[ext]' ,
339
343
} ,
340
344
} ,
345
+ // Process WebWorker JS with Babel.
346
+ // The preset includes JSX, Flow, TypeScript, and some ESnext features.
347
+ {
348
+ test : / \. w o r k e r \. ( j s | m j s | t s ) $ / ,
349
+ include : paths . appSrc ,
350
+ use : [
351
+ require . resolve ( 'worker-loader' ) ,
352
+ {
353
+ loader : require . resolve ( 'babel-loader' ) ,
354
+ options : {
355
+ customize : require . resolve (
356
+ 'babel-preset-react-app/webpack-overrides'
357
+ ) ,
358
+ // @remove -on-eject-begin
359
+ babelrc : false ,
360
+ configFile : false ,
361
+ presets : [ require . resolve ( 'babel-preset-react-app' ) ] ,
362
+ // Make sure we have a unique cache identifier, erring on the
363
+ // side of caution.
364
+ // We remove this when the user ejects because the default
365
+ // is sane and uses Babel options. Instead of options, we use
366
+ // the react-scripts and babel-preset-react-app versions.
367
+ cacheIdentifier : getCacheIdentifier (
368
+ isEnvProduction
369
+ ? 'production'
370
+ : isEnvDevelopment && 'development' ,
371
+ [
372
+ 'babel-plugin-named-asset-import' ,
373
+ 'babel-preset-react-app' ,
374
+ 'react-dev-utils' ,
375
+ 'react-scripts' ,
376
+ ]
377
+ ) ,
378
+ // @remove -on-eject-end
379
+ plugins : [
380
+ [
381
+ require . resolve ( 'babel-plugin-named-asset-import' ) ,
382
+ {
383
+ loaderMap : {
384
+ svg : {
385
+ ReactComponent :
386
+ '@svgr/webpack?-prettier,-svgo![path]' ,
387
+ } ,
388
+ } ,
389
+ } ,
390
+ ] ,
391
+ ] ,
392
+ // This is a feature of `babel-loader` for webpack (not Babel itself).
393
+ // It enables caching results in ./node_modules/.cache/babel-loader/
394
+ // directory for faster rebuilds.
395
+ cacheDirectory : true ,
396
+ cacheCompression : isEnvProduction ,
397
+ compact : isEnvProduction ,
398
+ } ,
399
+ } ,
400
+ ] ,
401
+ } ,
341
402
// Process application JS with Babel.
342
403
// The preset includes JSX, Flow, TypeScript, and some ESnext features.
343
404
{
0 commit comments