Closed aki77 closed 2 years ago
Hi.I think it can be done by resolving the path with vite alias before parse to sass.
It seems good to output the file read from the outside as a global, type definition.
It seems that the Vite css plugin solves this problem by passing the importer
option to sass.
@aki77 Thank you. We have released the issue in response. Changed to use the set option for loading sass.
Thanks!
I got rid of the import error
, but it seems that the d.ts
is not created in my environment.
I'll try to prepare a minimal reproduction environment when I have time.
Hi,
I think I'm running into a similar issue: I have a app/javascript/styles/global/index.scss
that imports several other files:
@import "./invoice";
@import "./admin";
@import "./loggedout";
// and so on
This works fine with vite, but with vite-plugin-sass-dts, I get errors like
e :>> Error: Can't find stylesheet to import.
╷
1 │ @import "./invoice";";
│ ^^^^^^^^^^^^^^^^^^^^^^
╵
stdin 1:9 root stylesheet
at Object._newRenderError (/home/maciek/code/project/node_modules/sass/sass.dart.js:2203:19)
at Object._wrapException (/home/maciek/code/project/node_modules/sass/sass.dart.js:2023:16)
at StaticClosure._renderSync (/home/maciek/code/project/node_modules/sass/sass.dart.js:2000:18)
at Object.Primitives_applyFunction (/home/maciek/code/project/node_modules/sass/sass.dart.js:6527:30)
at Object.Function_apply (/home/maciek/code/project/node_modules/sass/sass.dart.js:13854:16)
at _callDartFunctionFast (/home/maciek/code/project/node_modules/sass/sass.dart.js:15560:16)
at /home/maciek/code/project/node_modules/sass/sass.dart.js:15538:18
at parseCss (/home/maciek/code/project/node_modules/vite-plugin-sass-dts/dist/css.js:9:42)
at async /home/maciek/code/project/node_modules/vite-plugin-sass-dts/dist/main.js:23:29 {
formatted: "Error: Can't find stylesheet to import.\n" +
' ╷\n' +
'1 │ @import "./invoice";";\n' +
' │ ^^^^^^^^^^^^^^^^^^^^^^\n' +
' ╵\n' +
' stdin 1:9 root stylesheet',
line: 1,
column: 9,
file: 'stdin',
status: 1
}
Are relative imports like this not supported? Also, we have several custom aliases added to our Vite config via
import { resolve } = from 'path';
export default defineConfig({
resolve: {
alias: {
"components": resolve(__dirname, "app/javascript/components'"),
"types": resolve(__dirname, "app/javascript/types"),
// and so on
}
},
Is duplicating all the relevant aliases in importer
the best solution?
@uhoh-itsmaciek
Hi, thanks contact. Please wait for confirmation.
@uhoh-itsmaciek
Must be passed with an absolute path
when compiling with scss.
Specify the file location with an absolute path in the importer
as shown below.
There was a bug when additonalData wasn't set, so I've fixed it and released 1.1.3
. Please get the latest version.
Sorry.
importer(...args) {
const reg = new RegExp(`\\./(invoice)($|\\?)`);
if (!reg.test(args[0])) {
return;
}
return {
file: `${path.resolve(
_dirname,
"./src/invoice.scss"
)}`,
};
},
The issue has no movement, so close it.
In the following cases,
Can't find stylesheet to import
errors will occur. Do you have any solutions?