Skip to content

Commit

Permalink
feat: update webpack to latest version
Browse files Browse the repository at this point in the history
  • Loading branch information
HumbertoL committed Feb 27, 2024
1 parent 218fef9 commit 6b19854
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 26 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
"docusaurus/website"
],
"scripts": {
"build": "cd packages/react-scripts && node bin/react-scripts.js build",
"build": "cd packages/react-scripts && node --openssl-legacy-provider bin/react-scripts.js build",
"changelog": "lerna-changelog",
"create-react-app": "node tasks/cra.js",
"e2e": "tasks/e2e-simple.sh",
"e2e:docker": "tasks/local-test.sh",
"postinstall": "npm run build:prod -w react-error-overlay",
"publish": "tasks/publish.sh",
"start": "cd packages/react-scripts && node bin/react-scripts.js start",
"start": "cd packages/react-scripts && node --openssl-legacy-provider bin/react-scripts.js start",
"screencast": "node ./tasks/screencast.js",
"screencast:error": "svg-term --cast jyu19xGl88FQ3poMY8Hbmfw8y --out screencast-error.svg --window --at 12000 --no-cursor",
"alex": "alex .",
Expand Down
3 changes: 0 additions & 3 deletions packages/react-scripts/config/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -301,9 +301,6 @@ module.exports = function (webpackEnv) {
// https://github.com/terser-js/terser/issues/120
inline: 2,
},
mangle: {
safari10: true,
},
// Added for profiling in devtools
keep_classnames: isEnvProductionProfile,
keep_fnames: isEnvProductionProfile,
Expand Down
31 changes: 15 additions & 16 deletions packages/react-scripts/config/webpackDevServer.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ const noopServiceWorkerMiddleware = require('react-dev-utils/noopServiceWorkerMi
const ignoredFiles = require('react-dev-utils/ignoredFiles');
const redirectServedPath = require('react-dev-utils/redirectServedPathMiddleware');
const paths = require('./paths');
const getHttpsConfig = require('./getHttpsConfig');

const host = process.env.HOST || '0.0.0.0';
const sockHost = process.env.WDS_SOCKET_HOST;
Expand Down Expand Up @@ -98,8 +97,8 @@ module.exports = function (proxy, allowedHost) {
// remove last slash so user can land on `/test` instead of `/test/`
publicPath: paths.publicUrlOrPath.slice(0, -1),
},

https: getHttpsConfig(),
// Text-em-all does not use HTTPs for the dev server
// https: getHttpsConfig(),
host,
historyApiFallback: {
// Paths with dots should still use the history fallback.
Expand All @@ -109,27 +108,27 @@ module.exports = function (proxy, allowedHost) {
},
// `proxy` is run between `before` and `after` `webpack-dev-server` hooks
proxy,
onBeforeSetupMiddleware(devServer) {
// Keep `evalSourceMapMiddleware`
// middlewares before `redirectServedPath` otherwise will not have any effect
// This lets us fetch source contents from webpack for the error overlay
setupMiddlewares: (middlewares, devServer) => {
if (!devServer) {
throw new Error('webpack-dev-server is not defined');
}

// Keep `evalSourceMapMiddleware` at the beginning
devServer.app.use(evalSourceMapMiddleware(devServer));

// Conditionally apply proxy setup middleware if exists
if (fs.existsSync(paths.proxySetup)) {
// This registers user provided middleware for proxy reasons
require(paths.proxySetup)(devServer.app);
}
},
onAfterSetupMiddleware(devServer) {
// Redirect to `PUBLIC_URL` or `homepage` from `package.json` if url not match

// Your existing onAfterSetupMiddleware logic can be applied directly
// Redirect to `PUBLIC_URL` or `homepage` from `package.json` if URL not matched
devServer.app.use(redirectServedPath(paths.publicUrlOrPath));

// This service worker file is effectively a 'no-op' that will reset any
// previous service worker registered for the same host:port combination.
// We do this in development to avoid hitting the production cache if
// it used the same host and port.
// https://github.com/facebook/create-react-app/issues/2272#issuecomment-302832432
// `noopServiceWorkerMiddleware` to avoid hitting production cache in development
devServer.app.use(noopServiceWorkerMiddleware(paths.publicUrlOrPath));

return middlewares; // Return the modified middlewares array
},
};
};
10 changes: 5 additions & 5 deletions packages/react-scripts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
"types": "./lib/react-app.d.ts",
"dependencies": {
"@babel/core": "^7.16.0",
"@pmmmwh/react-refresh-webpack-plugin": "^0.5.3",
"@svgr/webpack": "^5.5.0",
"@pmmmwh/react-refresh-webpack-plugin": "^0.5.11",
"@svgr/webpack": "^8.1.0",
"babel-jest": "^27.4.2",
"babel-loader": "^8.2.3",
"babel-plugin-named-asset-import": "^0.3.8",
Expand Down Expand Up @@ -70,11 +70,11 @@
"source-map-loader": "^3.0.0",
"style-loader": "^3.3.1",
"tailwindcss": "^3.0.2",
"terser-webpack-plugin": "^5.2.5",
"terser-webpack-plugin": "^5.3.10",
"url": "^0.11.0",
"webpack": "^5.64.4",
"webpack": "^5.90.3",
"webpack-bundle-analyzer": "4.5.0",
"webpack-dev-server": "^4.6.0",
"webpack-dev-server": "^5.0.2",
"webpack-manifest-plugin": "^4.0.2",
"workbox-webpack-plugin": "^6.4.1"
},
Expand Down

0 comments on commit 6b19854

Please sign in to comment.