Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CSS Modules composes with SASS files #15655

Open
mrequs opened this issue Dec 15, 2022 · 4 comments
Open

CSS Modules composes with SASS files #15655

mrequs opened this issue Dec 15, 2022 · 4 comments
Labels

Comments

@mrequs
Copy link

mrequs commented Dec 15, 2022

Environment

  • Operating System: Darwin
  • Node Version: v16.15.1
  • Nuxt Version: 3.0.0
  • Nitro Version: 1.0.0
  • Package Manager: [email protected]
  • Builder: vite
  • User Config: css, webpack, vite
  • Runtime Modules: -
  • Build Modules: -

Reproduction

File: assets/typo.module.scss

$color: red;

.h1 {
  color: $color;
}

File: pages/index.vue

<template>
   <h1 :class="$style.title">Home page</h1>
</template>

<style lang="scss" module>
.title {
  composes: h1 from '~/assets/typo.module.scss';
  color: yellow;
}
</style>

Describe the bug

The compose in CSS modules doesn't work with SCSS files.

In this case the scss file is loaded as regular css file, it's not compiled from scss to css,
when i try use other loader like (what i do in Nuxt2, where it's work):

composes: h1 from 'sass-loader!~/assets/typo.module.scss';

I got error 500 with message:
Cannot read properties of undefined (reading 'length')

I tried with different loaders (postcss-loader, etc.) other aliases (@/) and the result always be the same

Additional context

No response

Logs

[[vite-node] [VITE_ERROR] /pages/index.vue?vue&type=style&index=0&lang.module.scss                                                                                        20:25:30
at /pages/index.vue?vue&type=style&index=0&lang.module.scss ] {
  statusCode: 500,
  fatal: false,
  unhandled: false,
  statusMessage: 'Vite Error',
  __nuxt_error: true
}

 ERROR  20:25:30 [vite] Internal server error: Cannot read properties of undefined (reading 'length')                                                                    20:25:30
      at memoizedBinarySearch (file:///UserPath/nuxt3/node_modules/vite/dist/node/chunks/dep-5605cfa4.js:9948:25)
      at traceSegmentInternal (file:///UserPath/nuxt3/node_modules/vite/dist/node/chunks/dep-5605cfa4.js:10055:17)
      at originalPositionFor$1 (file:///UserPath/nuxt3/node_modules/vite/dist/node/chunks/dep-5605cfa4.js:10041:23)
      at formatError (file:///UserPath/nuxt3/node_modules/vite/dist/node/chunks/dep-5605cfa4.js:40343:54)
      at TransformContext.error (file:///UserPath/nuxt3/node_modules/vite/dist/node/chunks/dep-5605cfa4.js:40277:19)
      at Object.transform (file:///UserPath/nuxt3/node_modules/vite/dist/node/chunks/dep-5605cfa4.js:40537:25)
      at async loadAndTransform (file:///UserPath/nuxt3/node_modules/vite/dist/node/chunks/dep-5605cfa4.js:36921:29)
@manniL
Copy link
Member

manniL commented Dec 15, 2022

Could you tests if this works as expected in plain Vite + Vue?

@mrequs
Copy link
Author

mrequs commented Dec 15, 2022

Could you tests if this works as expected in plain Vite + Vue?

looks the same, apparently it's a vite problem itself

@manniL
Copy link
Member

manniL commented Dec 15, 2022

Then it'd be great to open an issue there 👍 Feel free to link this one then ☺️

@mrequs
Copy link
Author

mrequs commented Dec 15, 2022

@manniL looks it's related with vitejs/vite#10340

@danielroe danielroe added the 3.x label Jan 19, 2023
@danielroe danielroe transferred this issue from nuxt/framework Jan 19, 2023
@danielroe danielroe removed the 3.x label Jun 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants