-
-
Notifications
You must be signed in to change notification settings - Fork 52
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)) |
This comment was marked as off-topic.
This comment was marked as off-topic.
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 }
);
}
},
},
]
}
}) |
This comment was marked as spam.
This comment was marked as spam.
This comment was marked as abuse.
This comment was marked as abuse.
Hi @tgrushka, sorry to hear you're frustrated. To be fair, it's not common for people to want their
See this comment.
Maybe it can, but that would require someone who cares to implement it. Adding more maintenance burden for a fringe use case is probably out of scope, though.
I sympathize with this frustration. Sadly, everyone expects free work from maintainers. There really needs to be a VC-funded, full-stack TypeScript framework that embodies the Rails/Laravel philosophy. There might already be one? I haven't looked, since I enjoy the freedom and power of piecing together different tools into my own quasi-framework. Anywho, wishing you the best. I know the ecosystem can be annoying at times (for some people, all the time). 💙 |
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: