Skip to content

About

Composable webpack blocks, runtime env injection, and YAML design tokens for Sass

Resources

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

build-toolkit

Composable webpack blocks, runtime env injection, and YAML design tokens for Sass.

Three small, focused packages that work alone or together:

Package Description
@build-toolkit/webpack-blocks Webpack configs as plain Configuration fragments composed with webpack-merge, plus webpack-build / webpack-dev CLIs that load TypeScript configs via jiti and drive the webpack Node API directly
@build-toolkit/env Build-time dotenv loading with CRA-style priority, explicit client-env allowlisting, and window._env_ runtime injection — change env vars without rebuilding
@build-toolkit/sass-tokens Design tokens as YAML, consumed from Sass as SCSS maps via a custom importer, or extracted to JS with createTokenMap

📖 Documentation — guides plus a TypeDoc-generated API reference (pnpm docs:dev to run locally).

Quick start

pnpm add -D @build-toolkit/webpack-blocks webpack webpack-dev-server jiti \
            esbuild-loader style-loader css-loader
// webpack.config.ts
import { merge } from "webpack-merge";
import { makeBaseBlock, makeHtmlWebpackPluginBlock } from "@build-toolkit/webpack-blocks";

const isProd = process.env.NODE_ENV === "production";

export default merge(
  makeBaseBlock({
    mode: isProd ? "production" : "development",
    entry: { index: "./src/index.ts" },
    cwd: process.cwd(),
    shouldExtractCss: isProd,
  }),
  makeHtmlWebpackPluginBlock({ title: "My App" }),
);
pnpm exec webpack-build   # production build → dist/
pnpm exec webpack-dev     # dev server with HMR

A complete, continuously-tested example lives in test-app/.

Repository layout

packages/
  env/             @build-toolkit/env
  sass-tokens/     @build-toolkit/sass-tokens
  webpack-blocks/  @build-toolkit/webpack-blocks
docs/              Astro Starlight docs site (typedoc API reference)
test-app/          E2E harness — real webpack build asserted in CI

Development

Requirements: Node ≥ 22.13 (a pnpm 11 requirement — the published packages themselves support Node ≥ 20), pnpm 11.

pnpm install
pnpm build        # turbo: build all packages (+ test-app integration build)
pnpm test         # unit tests + the test-app E2E webpack build
pnpm lint         # eslint (typescript-eslint + @stylistic)
pnpm check:types  # tsc --noEmit everywhere
pnpm docs:dev     # docs site at localhost:4321

Releasing

Versioning and publishing are handled by changesets:

pnpm changeset        # describe your change (pick bump levels)
pnpm version          # apply pending changesets (CI usually does this)
pnpm release          # build + publish (CI usually does this)

See CONTRIBUTING.md for the full workflow.

License

MIT © Christopher Coppola

About

Composable webpack blocks, runtime env injection, and YAML design tokens for Sass

Resources

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages