Skip to content

Separate scratch Webpack config#1417

Open
zetter-rpf wants to merge 2 commits intomainfrom
separate-scratch-webpack-config
Open

Separate scratch Webpack config#1417
zetter-rpf wants to merge 2 commits intomainfrom
separate-scratch-webpack-config

Conversation

@zetter-rpf
Copy link
Copy Markdown
Contributor

Related to: https://github.com/RaspberryPiFoundation/digital-editor-issues/issues/1278#issue-4168506145

  • Separates out the config required for Scratch to make our webpack config easier to understand
  • Avoid modifying the Scratch GUI library or bundling it with our own code

See commits for more detail

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.
@zetter-rpf zetter-rpf force-pushed the separate-scratch-webpack-config branch from 73fdd7c to 6695cd3 Compare April 2, 2026 14:56
@zetter-rpf zetter-rpf marked this pull request as ready for review April 2, 2026 14:56
Copilot AI review requested due to automatic review settings April 2, 2026 14:56
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.js into shared moduleRules, plus mainConfig and scratchConfig, exported as a multi-config array.
  • Updates the Scratch build to externalize @scratch/scratch-gui, react, react-dom, redux, and react-redux, and copies their prebuilt UMD bundles into build/vendor/.
  • Updates src/scratch.html to 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants