Skip to content

docs: use the built-in CSS support of webpack in examples - #609

Merged
alexander-akait merged 1 commit into
mainfrom
claude/webpack-css-examples-tests-lvv3kf
Aug 29, 2026
Merged

docs: use the built-in CSS support of webpack in examples#609
alexander-akait merged 1 commit into
mainfrom
claude/webpack-css-examples-tests-lvv3kf

Conversation

@alexander-akait

Copy link
Copy Markdown
Member

Updates the README examples to webpack's built-in CSS support and adds test coverage for that setup.

Documentation

Every config example now uses experiments.css and the css/auto module type instead of chaining style-loader and css-loader:

{
  test: /\.less$/i,
  type: "css/auto",
  use: ["less-loader"],
}
// + experiments: { css: true }

The surrounding prose was updated to match, not just the code blocks:

  • Getting Started notes that experiments.css has to be enabled, and links to the loader-chain section for anyone who still needs it.
  • Normal usage explains css/auto vs css vs css/module.
  • New Using css-loader and style-loader section keeps the old chain documented.
  • In production / Extracting style sheets now explain that built-in CSS extracts style sheets on its own (pointing at output.cssFilename), and mention MiniCssExtractPlugin only for the loader-chain path. The dead extract-loader link was dropped.
  • CSS modules gotcha became a proper CSS modules section with a working example; the url(...) caveat is kept.

Tests

New test/built-in-css.test.js (7 tests), driven by a new test/helpers/getCssCompiler.js that builds a compiler with experiments.css, type: "css/auto" and output.pathinfo: false (so snapshots aren't polluted by webpack's path banner). Coverage:

  • plain CSS output and @import resolution (relative and through node_modules)
  • url() asset emission and rewriting
  • CSS modules class-name renaming
  • lessOptions and additionalData passthrough
  • source maps: the generated map references the original .less file and carries its source content
  • error reporting on a broken file

Fixtures live in test/fixtures/built-in-css/. pathinfo was added to .cspell.json.

Notes

  • The existing tests keep using testLoader.cjs to capture raw loader output. Converting them would mean asserting against webpack's CSS-parser output rather than less-loader's, which is a weaker assertion, so built-in CSS coverage was added alongside instead of replacing them.
  • The CSS modules test uses a .module.less entry rather than a JS entry importing it: Node's test runner treats every .js file under test/ as a test file, so a JS fixture importing .less would fail as a "test". Narrowing the runner's glob would break test:coverage, since Node ignores flags placed after positional patterns.
  • No changeset — docs and tests only, no source change.

Full test suite and npm run lint (eslint, cspell, tsc, prettier) pass locally.

🤖 Generated with Claude Code

https://claude.ai/code/session_017wwBzDKPnXaC6vFomCtu42


Generated by Claude Code

Rewrite the README examples to rely on `experiments.css` and the
`css/auto` module type instead of chaining `style-loader` and
`css-loader`, and keep the loader chain setup documented in a dedicated
section for anyone who still needs it.

Add tests covering the loader with the built-in CSS support of webpack:
plain CSS, CSS modules, `url()` handling, source maps, `lessOptions`,
`additionalData` and error reporting.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017wwBzDKPnXaC6vFomCtu42
@changeset-bot

changeset-bot Bot commented Aug 29, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: f33f4c4

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@codecov

codecov Bot commented Aug 29, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.61%. Comparing base (45b1042) to head (f33f4c4).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #609   +/-   ##
=======================================
  Coverage   96.61%   96.61%           
=======================================
  Files           2        2           
  Lines         649      649           
=======================================
  Hits          627      627           
  Misses         22       22           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@alexander-akait
alexander-akait merged commit 85812ac into main Aug 29, 2026
16 checks passed
@alexander-akait
alexander-akait deleted the claude/webpack-css-examples-tests-lvv3kf branch August 29, 2026 11:30
alexander-akait added a commit that referenced this pull request Aug 29, 2026
Follow-up to #609. Allow the module `type` of the rule to be configured in
the `getCssCompiler` helper and add tests for it:

- the `css` type keeps local class names of a `*.module.less` file
- the `css/module` type renames local class names of any file
- a `Less` warning is reported as a webpack warning

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015mWLDEnMwEUsTLYX1akDLL
alexander-akait added a commit that referenced this pull request Aug 29, 2026
Follow-up to #609. Allow the module `type` of the rule to be configured in
the `getCssCompiler` helper and add tests for it:

- the `css` type keeps local class names of a `*.module.less` file
- the `css/module` type renames local class names of any file
- a `Less` warning is reported as a webpack warning


Claude-Session: https://claude.ai/code/session_015mWLDEnMwEUsTLYX1akDLL

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
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.

1 participant