Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

docs: add docs for the css experiment #6919

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
chenxsan merged 7 commits into webpack:main from burhanuday:docs/css-exp-docs
Jun 24, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions src/content/configuration/experiments.mdx
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ contributors:
- chenxsan
- anshumanv
- snitin315
- burhanuday
---

## experiments
Expand Down Expand Up @@ -184,6 +185,35 @@ Detect changes to remote resources and upgrade them automatically.

Enable native CSS support. Note that it's an experimental feature still under development and will be enabled by default in webpack v6, however you can track the progress on [GitHub](https://github.com/webpack/webpack/issues/14893).

- Type:

- `boolean`
- `CssExperimentOptions`

```ts
{
exportsOnly?: boolean;
}
```

Experimental features:

- CSS Modules support: webpack will generate a unique name for each CSS class. Use the `.module.css` extension for CSS Modules.
- <Badge text="5.87.0+" /> Style-specific fields resolution in `package.json` files:
webpack will look for `style` field in `package.json` files and use that if it
exists for imports inside CSS files.
Copy link
Member

Choose a reason for hiding this comment

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

Maybe include an example for this list item?

Copy link
Member

Choose a reason for hiding this comment

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

Btw, did you insert many soft line breaks?

Copy link
Member Author

@burhanuday burhanuday Jun 23, 2023

Choose a reason for hiding this comment

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

Btw, did you insert many soft line breaks?

Strange. The line break gets added by prettier. Was able to remove it from one point but not the other

Copy link
Member Author

@burhanuday burhanuday Jun 23, 2023

Choose a reason for hiding this comment

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

Maybe include an example for this list item?

It is a little difficult to explain that point with an example since it has to do with module resolution inside of node_modules folder. Will give it a try

Copy link
Member Author

@burhanuday burhanuday Jun 23, 2023

Choose a reason for hiding this comment

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

Maybe include an example for this list item?

Added an example with using bootstrap since they do have that field in their package.json file https://github.com/twbs/bootstrap/blob/main/package.json#L40

Copy link
Member Author

@burhanuday burhanuday Jun 23, 2023

Choose a reason for hiding this comment

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

Btw, did you insert many soft line breaks?

This is happening due to MDX component Badge. VSCode considers the file as markdown and thats just how it formats it for me 😅


For example, if you add `@import 'bootstrap';` to your CSS file, webpack will look for `bootstrap` in `node_modules` and use the `style` field in `package.json` from there. If `style` field is not found, webpack will use the `main` field instead to preserve backward compatibility.

- Content hash for CSS files: webpack will generate a content hash for CSS files and use it in the filename. This is useful for long-term caching.
- CSS extraction: webpack will extract CSS into a separate file. This functionality replaces the need for `mini-css-extract-plugin` and `css-loader`, as it provides native support.
- CSS imports: webpack will inline CSS imports into the generated CSS file.
- Hot Module Reload (HMR): webpack supports HMR for CSS files. This means that changes made to CSS files will be reflected in the browser without a full page reload.

#### experiments.css.exportsOnly

Avoid generating and loading a stylesheet and only embed exports from css into output javascript files.

- Type: `boolean`

### experiments.cacheUnaffected
Expand Down

AltStyle によって変換されたページ (->オリジナル) /