-
-
Notifications
You must be signed in to change notification settings - Fork 43
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
Doesn't work with scss file #30
Comments
|
Unfortunately, after setting |
edit: Oh I missed this part of that issue:
I wonder, is the |
Hi, @aleclarson . Maybe reopen this issue? I'm getting similar errors on my side. Trying to jump to vite from webpack. |
If someone can reproduce this in the |
@aleclarson hi, yes, I've done a demo, it's here: https://github.com/MetaMmodern/vite-tsconfig-paths/tree/scss-test. Should I make a PR? Btw, if I try to resolve with using just vite it kinda works, in a way that it does not throw errors, but my app looks like it hasn't downloaded styles.. |
This comment was marked as spam.
This comment was marked as spam.
Any updates ? I have this config export default defineConfig({
plugins: [react(), tsconfigPaths()],
server: {
port: 3000
}
}) And I get this error :
I found a workaround by manually adding paths to be resolved by vite. export default defineConfig({
plugins: [react(), tsconfigPaths()],
server: {
port: 3000
},
resolve: {
alias: {
"scss": path.resolve(__dirname, "src/scss")
}
}
}) Thanks |
This is an upstream bug in Vite. The resolver used by |
Once this PR is merged, I have confirmed this will be fixed. (But you have to use Thank you @MetaMmodern for the reproduction! |
@aleclarson omg, it's been 10 month, thank you)) |
@aleclarson I added loose: true but not working in SCSS |
I was involved in trouble too…But for now, I’ve used a hack way to achieve what I want const resolvePlugin = tsconfigPaths({
// to support resolve alias in scss files(any other non-script files)
loose: true,
})
export default defineConfig({
resolve: {
alias: [
{
find: /(.*)/,
replacement: '$1',
async customResolver(source, importer, options) {
// HACK: resolve ts alias in style files.
if (importer && /\.scss/.test(importer)) {
// @ts-ignore
return await resolvePlugin.resolveId.call(
this,
source,
importer,
{ skipSelf: true }
);
}
},
},
]
}
}) |
config:
tsconfig.json:
I set baseUrl to
src
dir, and import some scss by@use 'style/color'
(there is a file in /src/style/color.scss )Everything works fine when I manually configure the alias, but when I use
vite-tsconfig-paths
it throws an error:The text was updated successfully, but these errors were encountered: