Skip to content

Commit 5f34fac

Browse files
committed
update webpack config
1 parent 50ba277 commit 5f34fac

File tree

1 file changed

+16
-11
lines changed

1 file changed

+16
-11
lines changed

packages/react-scripts/config/webpack.config.wptheme.js

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@ const WorkboxWebpackPlugin = require('workbox-webpack-plugin');
2727
const WatchMissingNodeModulesPlugin = require('react-dev-utils/WatchMissingNodeModulesPlugin');
2828
const ModuleScopePlugin = require('react-dev-utils/ModuleScopePlugin');
2929
const getCSSModuleLocalIdent = require('react-dev-utils/getCSSModuleLocalIdent');
30-
// const paths = require('./paths'); // wptheme - remarked out
31-
const paths = require('./paths-wptheme'); // wptheme - added
30+
const paths = require('./paths-wptheme'); // wptheme modified
3231
const modules = require('./modules');
3332
const getClientEnvironment = require('./env');
3433
const ModuleNotFoundPlugin = require('react-dev-utils/ModuleNotFoundPlugin');
@@ -117,7 +116,7 @@ module.exports = function(webpackEnv) {
117116
// common function to get style loaders
118117
const getStyleLoaders = (cssOptions, preProcessor) => {
119118
const loaders = [
120-
isEnvDevelopment && require.resolve('style-loader'),
119+
// isEnvDevelopment && require.resolve('style-loader'),
121120
// isEnvProduction && // wptheme remarked out -- always use MiniCssExtractPlugin to generate css
122121
{
123122
loader: MiniCssExtractPlugin.loader,
@@ -204,8 +203,7 @@ module.exports = function(webpackEnv) {
204203
].filter(Boolean),
205204
output: {
206205
// The build folder.
207-
//path: isEnvProduction ? paths.appBuild : undefined, // wptheme remarked out
208-
path: isEnvProduction ? paths.appBuild : paths.appBuild, // wptheme added
206+
path: isEnvProduction ? paths.appBuild : paths.appBuild, // wptheme modified
209207
// Add /* filename */ comments to generated require()s in the output.
210208
pathinfo: isEnvDevelopment,
211209
// There will be one main bundle, and one file per asynchronous chunk.
@@ -254,7 +252,7 @@ module.exports = function(webpackEnv) {
254252
comparisons: false,
255253
// Disabled because of an issue with Terser breaking valid code:
256254
// https://github.com/facebook/create-react-app/issues/5250
257-
// Pending futher investigation:
255+
// Pending further investigation:
258256
// https://github.com/terser-js/terser/issues/120
259257
inline: 2,
260258
},
@@ -304,7 +302,10 @@ module.exports = function(webpackEnv) {
304302
},
305303
// Keep the runtime chunk separated to enable long term caching
306304
// https://twitter.com/wSokra/status/969679223278505985
307-
runtimeChunk: true,
305+
// https://github.com/facebook/create-react-app/issues/5358
306+
runtimeChunk: {
307+
name: entrypoint => `runtime-${entrypoint.name}`,
308+
},
308309
},
309310
resolve: {
310311
// This allows you to set a fallback for where Webpack should look for modules.
@@ -361,6 +362,7 @@ module.exports = function(webpackEnv) {
361362
use: [
362363
{
363364
options: {
365+
cache: true,
364366
formatter: require.resolve('react-dev-utils/eslintFormatter'),
365367
eslintPath: require.resolve('eslint'),
366368
resolvePluginsRelativeTo: __dirname,
@@ -375,7 +377,7 @@ module.exports = function(webpackEnv) {
375377
}
376378

377379
// We allow overriding the config only if the env variable is set
378-
if (process.env.EXTEND_ESLINT && eslintConfig) {
380+
if (process.env.EXTEND_ESLINT === 'true' && eslintConfig) {
379381
return eslintConfig;
380382
} else {
381383
return {
@@ -456,7 +458,8 @@ module.exports = function(webpackEnv) {
456458
// It enables caching results in ./node_modules/.cache/babel-loader/
457459
// directory for faster rebuilds.
458460
cacheDirectory: true,
459-
cacheCompression: isEnvProduction,
461+
// See #6846 for context on why cacheCompression is disabled
462+
cacheCompression: false,
460463
compact: isEnvProduction,
461464
},
462465
},
@@ -477,7 +480,8 @@ module.exports = function(webpackEnv) {
477480
],
478481
],
479482
cacheDirectory: true,
480-
cacheCompression: isEnvProduction,
483+
// See #6846 for context on why cacheCompression is disabled
484+
cacheCompression: false,
481485
// @remove-on-eject-begin
482486
cacheIdentifier: getCacheIdentifier(
483487
isEnvProduction
@@ -621,9 +625,10 @@ module.exports = function(webpackEnv) {
621625
),
622626
// Inlines the webpack runtime script. This script is too small to warrant
623627
// a network request.
628+
// https://github.com/facebook/create-react-app/issues/5358
624629
isEnvProduction &&
625630
shouldInlineRuntimeChunk &&
626-
new InlineChunkHtmlPlugin(HtmlWebpackPlugin, [/runtime~.+[.]js/]),
631+
new InlineChunkHtmlPlugin(HtmlWebpackPlugin, [/runtime-.+[.]js/]),
627632
// Makes some environment variables available in index.html.
628633
// The public URL is available as %PUBLIC_URL% in index.html, e.g.:
629634
// <link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico">

0 commit comments

Comments
 (0)