Open
Conversation
I want to split out the Scratch config and this will be shared between them
Our webpack config has grown to support our new scratch entry file. I've separated out the Scratch specific config needed for this entrypoint. As part of this I have also made sure the code from the scratch-gui is kept in a separate file from our code and not modified as part of our build process so we are better following the requirements of the Scratch license. Because Scratch has peer dependencies (react, react-dom, redux, redux-react) I've had to configure these as external dependencies and set them on window in the way that Scratch expects. These dependencies will load first, then Scratch and then our compiled scratch.jsx.
73fdd7c to
6695cd3
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
This PR splits the existing single Webpack configuration into separate “main app” and “Scratch” builds, with the Scratch build treating Scratch GUI (and key React/Redux deps) as external vendor scripts rather than bundling them into the project’s own output.
Changes:
- Refactors
webpack.config.jsinto sharedmoduleRules, plusmainConfigandscratchConfig, exported as a multi-config array. - Updates the Scratch build to externalize
@scratch/scratch-gui,react,react-dom,redux, andreact-redux, and copies their prebuilt UMD bundles intobuild/vendor/. - Updates
src/scratch.htmlto load the new vendor scripts and set expected globals before the Scratch app bundle runs.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| webpack.config.js | Splits into mainConfig + scratchConfig, adds Scratch externals, and copies vendor bundles/assets for Scratch. |
| src/scratch.html | Loads vendor React/Redux/Scratch GUI scripts and sets window globals used by the Scratch runtime. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related to: https://github.com/RaspberryPiFoundation/digital-editor-issues/issues/1278#issue-4168506145
See commits for more detail