Skip to content

Commit

Permalink
fix(css)!: remove default import in ssr dev (#17922)
Browse files Browse the repository at this point in the history
Co-authored-by: patak <583075+patak-dev@users.noreply.github.com>
  • Loading branch information
bluwy and patak-dev authored Oct 30, 2024
1 parent 61cbf6f commit eccf663
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 10 deletions.
7 changes: 3 additions & 4 deletions packages/vite/src/node/plugins/css.ts
Original file line number Diff line number Diff line change
Expand Up @@ -539,13 +539,12 @@ export function cssPostPlugin(config: ResolvedConfig): Plugin {
if (isDirectCSSRequest(id)) {
return null
}
// server only
if (this.environment.config.consumer !== 'client') {
return modulesCode || `export default ${JSON.stringify(css)}`
}
if (inlined) {
return `export default ${JSON.stringify(css)}`
}
if (this.environment.config.consumer === 'server') {
return modulesCode || 'export {}'
}

const cssContent = await getContentWithSourcemap(css)
const code = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,7 @@ describe('module runner initialization', async () => {

it('css is loaded correctly', async ({ runner }) => {
const css = await runner.import('/fixtures/test.css')
expect(css.default).toMatchInlineSnapshot(`
".test {
color: red;
}
"
`)
expect(css.default).toBe(undefined)
const module = await runner.import('/fixtures/test.module.css')
expect(module).toMatchObject({
default: {
Expand Down

0 comments on commit eccf663

Please sign in to comment.