You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We are using rollup-plugin-includepath and typescript-plugin-css-modules with scss includePaths configured, to be able to import React components and .module.scss modules in our components, without the need for relative references (../../../).
This works fine with both tsc and during development with vite start.
However, with vite build, we get an rollup-error caused by ?used parameter on the .scss files.
For example in our .tsx file:
import listItem from 'components/header/ListItem.module.scss';
and in our .scss file: @import 'scss/variables.module.scss';
As a workaround, I implemented a small rollup-plugin.
resolveId(source: string) {
if (source.endsWith('?used')) {
return { id: src/${source.slice(0, -'?used'.length)}, external: false };
}
return null;
},
Are we using these imports the wrong way, or is this a bug in vitejs?
[vite]: Rollup failed to resolve import "components/header/ListItem.module.scss?used" from "src\components\header\small\NavigationMenu.tsx".
This is most likely unintended because it can break your application at runtime.
If you do want to externalize this module explicitly add it to
`build.rollupOptions.external`
error during build:
Error: [vite]: Rollup failed to resolve import "components/header/ListItem.module.scss?used" from "src\components\header\small\NavigationMenu.tsx".
This is most likely unintended because it can break your application at runtime.
If you do want to externalize this module explicitly add it to
`build.rollupOptions.external`
Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
Make sure this is a Vite issue and not a framework-specific issue. For example, if it's a Vue SFC related bug, it should likely be reported to https://github.com/vuejs/vue-next instead.
I find that the plugin rollup-plugin-includepath seems to be obsolete and not maintained.
Are there any other recommended way to have scss typescript support with Vite + React Typescript, both in tsx-files and in scss-files?
Describe the bug
We are using rollup-plugin-includepath and typescript-plugin-css-modules with scss includePaths configured, to be able to import React components and .module.scss modules in our components, without the need for relative references (../../../).
This works fine with both tsc and during development with vite start.
However, with vite build, we get an rollup-error caused by ?used parameter on the .scss files.
For example in our .tsx file:
import listItem from 'components/header/ListItem.module.scss';
and in our .scss file:
@import 'scss/variables.module.scss';
In vitejs I found this that might cause the error for us:
3e3c203#diff-121079017d1fa98d6a0ea3354d5c73df45ab277078228cd7384c7a4e84c5a813R187
As a workaround, I implemented a small rollup-plugin.
resolveId(source: string) {
if (source.endsWith('?used')) {
return { id:
src/${source.slice(0, -'?used'.length)}
, external: false };}
return null;
},
Are we using these imports the wrong way, or is this a bug in vitejs?
Reproduction
Clone sample repository, npm install, npm run build
https://github.com/johannessorheim/Vite5811
This line triggers causes vite build to fail, and works with vite dev:
https://github.com/johannessorheim/Vite5811/blob/main/src/some/deep/folder/component.tsx#L4
System Info
Used Package Manager
npm
Logs
Validations
The text was updated successfully, but these errors were encountered: