Skip to content

Commit b32205f

Browse files
authored
Webpack v5 bump (#1096)
closes #1074
1 parent e582b65 commit b32205f

File tree

16 files changed

+1621
-3249
lines changed

16 files changed

+1621
-3249
lines changed

.github/workflows/ci-cd.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,8 @@ jobs:
9292
with:
9393
install: false
9494
start: |
95-
yarn start
9695
yarn start:wc
97-
wait-on: "http://localhost:3010, http://localhost:3011"
96+
wait-on: "http://localhost:3011"
9897
quiet: true
9998
env:
10099
REACT_APP_API_ENDPOINT: "https://test-editor-api.raspberrypi.org"

.github/workflows/deploy.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -123,11 +123,9 @@ jobs:
123123
env:
124124
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
125125

126-
- name: Build site and WC bundle
126+
- name: Build WC bundle
127127
run: |
128-
if [[ "${{ inputs.environment }}" == "production" ]]; then
129-
yarn build
130-
else
128+
if [[ "${{ inputs.environment }}" != "production" ]]; then
131129
yarn build:dev
132130
fi
133131
yarn build:wc

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
1313

1414
### Changed
1515

16+
- Upgrade to `webpack 5` (#1096)
1617
- Bump `pyodide` to `v0.26.2` (#1098)
1718

1819
### Fixed

config/webpack.config.js

Lines changed: 0 additions & 778 deletions
This file was deleted.

config/webpackDevServer.config.js

Lines changed: 8 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -15,55 +15,22 @@ const sockPort = process.env.WDS_SOCKET_PORT;
1515
module.exports = function (proxy, _allowedHost) {
1616
return {
1717
allowedHosts: "all",
18-
// Enable gzip compression of generated files.
1918
compress: true,
20-
// Enable hot reloading server. It will provide WDS_SOCKET_PATH endpoint
21-
// for the WebpackDevServer client so it can learn when the files were
22-
// updated. The WebpackDevServer client is included as an entry point
23-
// in the webpack development configuration. Note that only changes
24-
// to CSS are currently hot reloaded. JS changes will refresh the browser.
2519
hot: true,
26-
// Use 'ws' instead of 'sockjs-node' on server since we're using native
27-
// websockets in `webpackHotDevClient`.
2820
webSocketServer: "ws",
29-
// It is important to tell WebpackDevServer to use the same "publicPath" path as
30-
// we specified in the webpack config. When homepage is '.', default to serving
31-
// from the root.
32-
// remove last slash so user can land on `/test` instead of `/test/`
3321
devMiddleware: {
3422
publicPath: paths.publicUrlOrPath.slice(0, -1),
3523
},
3624
static: {
37-
// By default WebpackDevServer serves physical files from current directory
38-
// in addition to all the virtual build products that it serves from memory.
39-
// This is confusing because those files won’t automatically be available in
40-
// production build folder unless we copy them. However, copying the whole
41-
// project directory is dangerous because we may expose sensitive files.
42-
// Instead, we establish a convention that only files in `public` directory
43-
// get served. Our build script will copy `public` into the `build` folder.
44-
// In `index.html`, you can get URL of `public` folder with %PUBLIC_URL%:
45-
// <link rel="icon" href="%PUBLIC_URL%/favicon.ico">
46-
// In JavaScript code, you can access it with `process.env.PUBLIC_URL`.
47-
// Note that we only recommend to use `public` folder as an escape hatch
48-
// for files like `favicon.ico`, `manifest.json`, and libraries that are
49-
// for some reason broken when imported through webpack. If you just want to
50-
// use an image, put it in `src` and `import` it from JavaScript instead.
5125
directory: paths.appPublic,
5226
publicPath: paths.publicUrlOrPath,
53-
// By default files from `directory` will not trigger a page reload.
54-
// Reportedly, this avoids CPU overload on some systems.
55-
// https://github.com/facebook/create-react-app/issues/293
56-
// src/node_modules is not ignored to support absolute imports
57-
// https://github.com/facebook/create-react-app/issues/1065
5827
watch: {
5928
ignored: ignoredFiles(paths.appSrc),
6029
},
6130
},
6231
https: getHttpsConfig(),
6332
host,
6433
historyApiFallback: {
65-
// Paths with dots should still use the history fallback.
66-
// See https://github.com/facebook/create-react-app/issues/387.
6734
disableDotRule: true,
6835
index: paths.publicUrlOrPath,
6936
},
@@ -76,44 +43,39 @@ module.exports = function (proxy, _allowedHost) {
7643
"Cross-Origin-Embedder-Policy": "require-corp",
7744
},
7845
client: {
79-
// Silence WebpackDevServer's own logs since they're generally not useful.
80-
// It will still show compile warnings and errors with this setting.
8146
logging: "none",
8247
overlay: false,
8348
webSocketURL: {
84-
// Enable custom sockjs pathname for websocket connection to hot reloading server.
85-
// Enable custom sockjs hostname, pathname and port for websocket connection
86-
// to hot reloading server.
8749
hostname: sockHost,
8850
pathname: sockPath,
8951
port: sockPort,
9052
},
9153
},
92-
// `proxy` is run between `before` and `after` `webpack-dev-server` hooks
9354
proxy,
94-
onBeforeSetupMiddleware(devServer) {
55+
setupMiddlewares: (middlewares, devServer) => {
9556
// Keep `evalSourceMapMiddleware` and `errorOverlayMiddleware`
9657
// middlewares before `redirectServedPath` otherwise will not have any effect
9758
// This lets us fetch source contents from webpack for the error overlay
98-
devServer.app.use(evalSourceMapMiddleware(devServer));
59+
middlewares.unshift(evalSourceMapMiddleware(devServer));
9960
// This lets us open files from the runtime error overlay.
100-
devServer.app.use(errorOverlayMiddleware());
61+
middlewares.unshift(errorOverlayMiddleware());
10162

10263
if (fs.existsSync(paths.proxySetup)) {
10364
// This registers user provided middleware for proxy reasons
10465
require(paths.proxySetup)(devServer.app);
10566
}
106-
},
107-
onAfterSetupMiddleware(devServer) {
67+
10868
// Redirect to `PUBLIC_URL` or `homepage` from `package.json` if url not match
109-
devServer.app.use(redirectServedPath(paths.publicUrlOrPath));
69+
middlewares.push(redirectServedPath(paths.publicUrlOrPath));
11070

11171
// This service worker file is effectively a 'no-op' that will reset any
11272
// previous service worker registered for the same host:port combination.
11373
// We do this in development to avoid hitting the production cache if
11474
// it used the same host and port.
11575
// https://github.com/facebook/create-react-app/issues/2272#issuecomment-302832432
116-
devServer.app.use(noopServiceWorkerMiddleware(paths.publicUrlOrPath));
76+
middlewares.push(noopServiceWorkerMiddleware(paths.publicUrlOrPath));
77+
78+
return middlewares;
11779
},
11880
};
11981
};

cypress.config.mjs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
import { defineConfig } from "cypress";
2+
import dotenv from "dotenv";
3+
4+
dotenv.config();
25

36
export default defineConfig({
47
e2e: {
@@ -20,4 +23,7 @@ export default defineConfig({
2023
openMode: 0,
2124
},
2225
},
26+
env: {
27+
REACT_APP_API_ENDPOINT: process.env.REACT_APP_API_ENDPOINT,
28+
},
2329
});

0 commit comments

Comments
 (0)