Skip to content
Merged
Show file tree
Hide file tree
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
19 changes: 19 additions & 0 deletions packages/vite/src/node/__tests__/plugins/css.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,25 @@ composes: bar from '@/css/bar.module.css';
const css = `\
.foo {
color: red;
}`
const result1 = await transform(css, '/foo.module.css') // server
const result2 = await transform(css, '/foo.module.css?direct') // client
expect(result1.code).toBe(result2.code)
})

test('custom generateScopedName with lightningcss', async () => {
const { transform } = await createCssPluginTransform({
configFile: false,
css: {
modules: {
generateScopedName: 'custom__[hash:base64:5]',
},
transformer: 'lightningcss',
},
})
const css = `\
.foo {
color: red;
}`
const result1 = await transform(css, '/foo.module.css') // server
const result2 = await transform(css, '/foo.module.css?direct') // client
Expand Down
2 changes: 1 addition & 1 deletion packages/vite/src/node/plugins/css.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3297,7 +3297,7 @@ async function compileLightningCSS(
const deps = new Set<string>()
// replace null byte as lightningcss treats that as a string terminator
// https://github.com/parcel-bundler/lightningcss/issues/874
const filename = id.replace('\0', NULL_BYTE_PLACEHOLDER)
const filename = removeDirectQuery(id).replace('\0', NULL_BYTE_PLACEHOLDER)

let res: LightningCssTransformAttributeResult | LightningCssTransformResult
try {
Expand Down