From 64fcdb0ca06894e86cc978a5c5150c6850edb9c0 Mon Sep 17 00:00:00 2001 From: Brice Dutheil Date: Thu, 1 Jul 2021 13:34:30 +0200 Subject: [PATCH] refactor(asset): Inline source maps to enable debug in JCEF The webapp is now built with a override of the default react-script webpack config, this override disables optimizations and inline source maps. Workaround of facebook/create-react-app#790, by using `react-script-rewired` and passing a custom webpack configuration override. The non-modifiable webpack config passed to react-script is located here : `excalidraw-assets/node_modules/react-scripts/config/webpack.config.js` Related to #7 --- excalidraw-assets/config-overrides.js | 14 ++++++++++++++ excalidraw-assets/package.json | 10 +++++----- excalidraw-assets/yarn.lock | 7 +++++++ 3 files changed, 26 insertions(+), 5 deletions(-) create mode 100644 excalidraw-assets/config-overrides.js diff --git a/excalidraw-assets/config-overrides.js b/excalidraw-assets/config-overrides.js new file mode 100644 index 00000000..8af8f11d --- /dev/null +++ b/excalidraw-assets/config-overrides.js @@ -0,0 +1,14 @@ +module.exports = function override(config, env) { + // see https://webpack.js.org/configuration/ + console.log("Disabling build minimizer (config-overrides.js)"); + config.mode = "development"; + config.optimization.minimize = false; + config.optimization.minimizer = []; + + // https://webpack.js.org/configuration/devtool/ + console.log("Inline SourceMaps (config-overrides.js)"); + config.devtool = 'inline-source-maps' + + + return config; +}; \ No newline at end of file diff --git a/excalidraw-assets/package.json b/excalidraw-assets/package.json index d2f4ac5b..f8452ee8 100644 --- a/excalidraw-assets/package.json +++ b/excalidraw-assets/package.json @@ -13,6 +13,7 @@ "@types/react-dom": "^17.0.8", "awesome-debounce-promise": "^2.1.0", "react": "^17.0.2", + "react-app-rewired": "^2.1.8", "react-dom": "^17.0.2", "react-scripts": "4.0.3", "typescript": "^4.3.4" @@ -29,10 +30,9 @@ ] }, "scripts": { - "start": "BROWSER=none cross-env NODE_ENV=development react-scripts start", - "build": "BUILD_PATH=./build/react-build/ react-scripts build && npx gulp", - "test": "react-scripts test --env=jsdom", - "eject": "react-scripts eject" + "start": "BROWSER=none cross-env NODE_ENV=development react-app-rewired start", + "build": "BUILD_PATH=./build/react-build/ react-app-rewired build && npx gulp", + "test": "react-app-rewired test --env=jsdom" }, "browserslist": { "production": [ @@ -46,4 +46,4 @@ "last 1 safari version" ] } -} \ No newline at end of file +} diff --git a/excalidraw-assets/yarn.lock b/excalidraw-assets/yarn.lock index f43a5fc0..97a106ff 100644 --- a/excalidraw-assets/yarn.lock +++ b/excalidraw-assets/yarn.lock @@ -9700,6 +9700,13 @@ react-app-polyfill@^2.0.0: regenerator-runtime "^0.13.7" whatwg-fetch "^3.4.1" +react-app-rewired@^2.1.8: + version "2.1.8" + resolved "https://registry.yarnpkg.com/react-app-rewired/-/react-app-rewired-2.1.8.tgz#e192f93b98daf96889418d33d3e86cf863812b56" + integrity sha512-wjXPdKPLscA7mn0I1de1NHrbfWdXz4S1ladaGgHVKdn1hTgKK5N6EdGIJM0KrS6bKnJBj7WuqJroDTsPKKr66Q== + dependencies: + semver "^5.6.0" + react-dev-utils@^11.0.3: version "11.0.4" resolved "https://registry.yarnpkg.com/react-dev-utils/-/react-dev-utils-11.0.4.tgz#a7ccb60257a1ca2e0efe7a83e38e6700d17aa37a"