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

Commit 09c41b7

Browse files
przemkowznck
andauthored
chore: update css module example to correctly handle <styles module> related options (#356)
Co-authored-by: Rahul Kadyan <hi@znck.me>
1 parent ce25256 commit 09c41b7

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
@@ -56,9 +56,9 @@ describe('css-modules', () => {
5656
expect(result.output[0].code).not.toEqual(
5757
expect.stringContaining('.red {\n color: red;\n}')
5858
)
59-
expect(result.output[0].code).toEqual(expect.stringContaining('._red_'))
59+
expect(result.output[0].code).toEqual(expect.stringContaining('.red___'))
6060
expect(result.output[0].code).toEqual(
61-
expect.stringContaining('{"red":"_red_')
61+
expect.stringContaining('{"red":"red___')
6262
)
6363
})
6464

@@ -67,7 +67,7 @@ describe('css-modules', () => {
6767
expect.stringContaining('.__scopeId = "data-v-')
6868
)
6969
expect(result.output[0].code).not.toEqual(
70-
expect.stringContaining('.green {\n color: red;\n}')
70+
expect.stringContaining('.green {\n color: green;\n}')
7171
)
7272
expect(result.output[0].code).toEqual(
7373
expect.stringContaining('.green[data-v-')

0 commit comments

Comments
 (0)