ember-scoped-css 2.1.0 → 2.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +29 -0
- package/dist/cjs/all-DxINxtbp.cjs +1416 -0
- package/dist/cjs/all.cjs +1 -1
- package/dist/cjs/babel.cjs +1 -1
- package/dist/cjs/rollup.cjs +1 -1
- package/dist/cjs/vite.cjs +1 -1
- package/package.json +4 -3
- package/src/build/template-plugin.js +53 -9
- package/src/build/template-plugin.test.ts +140 -1
- package/src/build/unplugin-colocated.js +54 -1
- package/src/build/unplugin-inline.js +53 -13
- package/src/lib/css/rewrite.js +18 -16
- package/src/lib/css/rewrite.test.ts +68 -52
- package/src/lib/css/utils.js +107 -3
- package/src/lib/request.js +10 -2
- package/dist/cjs/all-Bimr-GZ4.cjs +0 -1319
package/README.md
CHANGED
|
@@ -259,6 +259,35 @@ With `ember-scoped-css` you define styles in an inline `<style scoped>` block or
|
|
|
259
259
|
|
|
260
260
|
Note that `<style>` (without `scoped`) will continue to work as it does today and be "global styles"
|
|
261
261
|
|
|
262
|
+
### Using CSS preprocessors (eg. SCSS) with Vite
|
|
263
|
+
|
|
264
|
+
When using Vite, you can write preprocessor languages inside inline `<style>` blocks by using the `lang` attribute. The plugin uses Vite's `preprocessCSS` API to compile your preprocessor code to plain CSS during the build, then extracts and scopes classes from the compiled CSS.
|
|
265
|
+
|
|
266
|
+
Examples:
|
|
267
|
+
|
|
268
|
+
```gjs
|
|
269
|
+
<template>
|
|
270
|
+
<p class="scss-hi">hello from scss</p>
|
|
271
|
+
|
|
272
|
+
<style scoped lang="scss">
|
|
273
|
+
$color: rgb(200, 0, 100);
|
|
274
|
+
|
|
275
|
+
.scss-hi {
|
|
276
|
+
color: $color;
|
|
277
|
+
|
|
278
|
+
&:focus {
|
|
279
|
+
outline: none;
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
</style>
|
|
283
|
+
</template>
|
|
284
|
+
```
|
|
285
|
+
|
|
286
|
+
Notes:
|
|
287
|
+
|
|
288
|
+
- `lang` preprocessing is only supported when building with Vite. The plugin relies on Vite's `preprocessCSS` function. If you attempt to use `lang` without Vite, the build will throw a clear error.
|
|
289
|
+
- Inline styles with `lang` (for example `<style scoped inline lang="scss">`) are downgraded to a non-inline virtual module because preprocessing is asynchronous and cannot run at synchronous Babel-time; you will see a console warning informing you that the style was converted to a virtual CSS import.
|
|
290
|
+
|
|
262
291
|
<details><summary>inline / conditional CSS</summary>
|
|
263
292
|
|
|
264
293
|
Like the example above, we can specify the `scoped` attribute on the `<style>` tag, but if we add the `inline` attribute as well, the `<style>` tag will not be extracted to a CSS file during your app's build -- it will be left inline.
|