You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+17-8Lines changed: 17 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -163,16 +163,24 @@ Just point the input to a `.ts` file through either the cli or the `source` key
163
163
164
164
Microbundle will generally respect your TypeScript config defined in a `tsconfig.json` file with notable exceptions being the "[target](https://www.typescriptlang.org/tsconfig#target)" and "[module](https://www.typescriptlang.org/tsconfig#module)" settings. To ensure your TypeScript configuration matches the configuration that Microbundle uses internally it's strongly recommended that you set `"module": "ESNext"` and `"target": "ESNext"` in your `tsconfig.json`.
165
165
166
-
### Using CSS Modules
166
+
### CSS and CSS Modules
167
167
168
-
By default any css file imported as `.module.css`, will be treated as a css-module. If you wish to treat all .css
169
-
imports as a module, specify the cli flag `--css-modules true`. If you wish to disable all css-module behaviours set the
170
-
flag to `false`.
168
+
Importing CSS files is supported via `import "./foo.css"`. By default, generated CSS output is written to disk. The `--css inline` command line option will inline generated CSS into your bundles as a string, returning the CSS string from the import:
171
169
172
-
The default scope name when css-modules is turned on will be, in watch mode `_[name]__[local]__[hash:base64:5]` and when
173
-
you build `_[hash:base64:5]`. This can be overriden by specifying the flag, eg
174
-
`--css-modules "_something_[hash:base64:7]"`. _Note:_ by setting this, it will be treated as a true, and thus, all .css
175
-
imports will be scoped.
170
+
```js
171
+
// with the default external CSS:
172
+
import'./foo.css'; // generates a minified .css file in the output directory
173
+
174
+
// with `microbundle --css inline`:
175
+
importcssfrom'./foo.css';
176
+
console.log(css); // the generated minified stylesheet
177
+
```
178
+
179
+
**CSS Modules:** CSS files with names ending in `.module.css` are treated as a [CSS Modules](https://github.com/css-modules/css-modules).
180
+
To instead treat imported `.css` files as modules, run Microbundle with `--css-modules true`. To disable CSS Modules for your project, pass `--no-css-modules` or `--css-modules false`.
181
+
182
+
The default scope name for CSS Modules is`_[name]__[local]__[hash:base64:5]` in watch mode, and `_[hash:base64:5]` for production builds.
183
+
This can be customized by passing the command line argument `--css-modules "[name]_[hash:base64:7]"`, using [these fields and naming conventions](https://github.com/webpack/loader-utils#interpolatename).
0 commit comments