Skip to content
This repository was archived by the owner on Jan 18, 2022. It is now read-only.

Commit 0aa6bdc

Browse files
author
Przemyslaw Falowski
committed
chore: update css module example to correctly handle <styles module> related options
1 parent 0720102 commit 0aa6bdc

File tree

3 files changed

+8
-11
lines changed

3 files changed

+8
-11
lines changed

examples/css-modules/rollup.config.js

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,13 @@ const config = [
1515
// Resolve packages from `node_modules` e.g. `style-inject` module
1616
// used by `rollup-plugin-postcss` to inline CSS.
1717
NodeResolve(),
18-
VuePlugin(),
19-
// Process only `<style module>` blocks.
20-
PostCSS({
21-
modules: {
18+
VuePlugin({
19+
// PostCSS-modules options for <style module> compilation
20+
cssModulesOptions: {
2221
generateScopedName: '[local]___[hash:base64:5]',
2322
},
24-
include: /&module=.*\.css$/,
2523
}),
26-
// Process all `<style>` blocks except `<style module>`.
27-
PostCSS({ include: /(?<!&module=.*)\.css$/ }),
24+
PostCSS(),
2825
],
2926
external(id) {
3027
return /^(vue)$/.test(id)

examples/css-modules/src/App.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,6 @@ export default {
1818

1919
<style scoped>
2020
.green {
21-
color: red;
21+
color: green;
2222
}
2323
</style>

test/core.e2e.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@ describe('css-modules', () => {
4242
expect(result.output[0].code).not.toEqual(
4343
expect.stringContaining('.red {\n color: red;\n}')
4444
)
45-
expect(result.output[0].code).toEqual(expect.stringContaining('._red_'))
45+
expect(result.output[0].code).toEqual(expect.stringContaining('.red___'))
4646
expect(result.output[0].code).toEqual(
47-
expect.stringContaining('{"red":"_red_')
47+
expect.stringContaining('{"red":"red___')
4848
)
4949
})
5050

@@ -53,7 +53,7 @@ describe('css-modules', () => {
5353
expect.stringContaining('.__scopeId = "data-v-')
5454
)
5555
expect(result.output[0].code).not.toEqual(
56-
expect.stringContaining('.green {\n color: red;\n}')
56+
expect.stringContaining('.green {\n color: green;\n}')
5757
)
5858
expect(result.output[0].code).toEqual(
5959
expect.stringContaining('.green[data-v-')

0 commit comments

Comments
 (0)