Registry / devops / scratch-webpack-configuration

scratch-webpack-configuration

JSON →
library3.1.2jsnpmunverified

Shared webpack configuration builder for Scratch projects, version 3.1.2 as of March 2026. Provides a fluent API to construct webpack 5 configurations with defaults for Scratch's build pipeline, including Babel (with optional React), CSS (postcss-loader, css-loader, style-loader), TypeScript (ts-loader), asset modules via resource queries, chunk splitting, and target-specific externals for browserslist and Node. Released under BSD-3-Clause (was AGPL-3.0 in v2). Differentiators: opinionated but extensible via clone/merge, handles Scratch-specific module rules and externals, and integrates with Scratch's semantic release config. Requires webpack 5 and peer dependencies like @babel/preset-env, babel-loader, css-loader, postcss-loader, etc.

npm install scratch-webpack-configuration
INSTALL
IMPORT
SIG · SCRATCH-WEBPACK-CO
S
scratch-webpack-configuration
devopsjavascriptv3.1.2
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

ScratchWebpackConfigBuilder
import ScratchWebpackConfigBuilder from 'scratch-webpack-configuration';
const ScratchWebpackConfigBuilder = require('scratch-webpack-configuration');
ESM-only since v3; CommonJS require will fail.
ScratchWebpackConfigBuilder
import ScratchWebpackConfigBuilder from 'scratch-webpack-configuration';
Default export, not named. TypeScript: use default import.
ScratchWebpackConfigBuilder
import ScratchWebpackConfigBuilder from 'scratch-webpack-configuration';
import { ScratchWebpackConfigBuilder } from 'scratch-webpack-configuration';
Common mistake: using named import instead of default.

Shows creating a ScratchWebpackConfigBuilder, enabling React, setting target to browserslist, adding a CSS loader rule, and a CopyWebpackPlugin.

import ScratchWebpackConfigBuilder from 'scratch-webpack-configuration'; const builder = new ScratchWebpackConfigBuilder({ rootPath: __dirname, enableReact: true }) .setTarget('browserslist') .addModuleRule({ test: /\.css$/, use: ['style-loader', 'css-loader', 'postcss-loader'] }) .addPlugin(new (require('copy-webpack-plugin'))({ patterns: [{ from: 'public' }] })); export default builder.get();
Debug
Known issues
deprecatedv2.0.0 changed license from MIT to AGPL-3.0-only, then v3.0.0 reverted to BSD-3-Clause.
fix
Update to v3.0.0+ to use BSD-3-Clause license.
affects: >=2.0.0 <3.0.0
breakingv3.0.0 is ESM-only; CommonJS require() will throw.
fix
Use import syntax or dynamic import(). If you must use CommonJS, stay on v1.x (v2.x is also AGPL).
affects: >=3.0.0
gotchapeer dependencies must be installed manually; the package does not auto-install them.
fix
Install all peer deps listed in the package.json. Missing css-loader/url-loader will cause build failures.
affects: >=1.0.0
breakingv3.0.0 removed support for Node < 14; targets now require webpack 5.
fix
Ensure Node.js >=14 and webpack ^5.90.3.
affects: >=3.0.0
gotchaWhen using enableReact: true, you must install @babel/preset-react separately.
fix
Add @babel/preset-react to devDependencies.
affects: >=1.0.0
Errors
Common errors & fixes
Error: Cannot find module 'scratch-webpack-configuration'
Package not installed in node_modules.
fix
Run npm install scratch-webpack-configuration --save-dev
TypeError: ScratchWebpackConfigBuilder is not a constructor
Using named import instead of default import after switching to ESM.
fix
Change import { ScratchWebpackConfigBuilder } to import ScratchWebpackConfigBuilder
Module not found: Error: Can't resolve 'css-loader'
Missing peer dependency.
fix
npm install css-loader --save-dev
BREAKING CHANGE: The license for this project has changed back to BSD-3-Clause
Upgrading from v2 to v3 changes license.
fix
Update to v3 and review legal implications.
Upgrade
Version history
3.1.2latest on npm
Audit
Dependencies
webpackrequiredPeer dependency; the configuration generates webpack 5 config objects.
@babel/preset-envrequiredPeer dependency; used by babel-loader rule.
babel-loaderrequiredPeer dependency; processes JS/JSX files.
css-loaderrequiredPeer dependency; handles CSS imports.
postcss-loaderrequiredPeer dependency; processes PostCSS plugins.
style-loaderrequiredPeer dependency; injects CSS into DOM.
ts-loaderoptionalPeer dependency; TypeScript compilation (enableTs flag).
Agent activity
12 hits · last 30 days
node
12
Resources
scratch-webpack-configuration — npm install scratch-webpack-configuration · libregistry