importing 'additionalPaths'? #78
-
I'm trying to import some shared scss files stuck in my old I see in the migration guide that to reference code outside the sourceCodeDir we should add the additional paths with a glob, so in my vite.json I've added
How do we reference these files in a vue component? In particular in the stylesheet? When I try something like the following in a vue component
it looks that the path is still resolving to my |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Hi Gabriel! As it's mentioned in the Aliases section of the docs, the You have a few options to reference an outside file:
I'd recommend adding an alias in your import { resolve } from 'path'
import { defineConfig } from 'vite'
export default defineConfig({
resolve: {
alias: {
'@assets': resolve(__dirname, 'app/assets'),
},
}, There is a very similar alias being used in this example setup. I think this is common enough that it might be worth mentioning it in the docs. Let me know if that helps! |
Beta Was this translation helpful? Give feedback.
Hi Gabriel!
As it's mentioned in the Aliases section of the docs, the
~
prefix is an alias to your sourceCodeDir, which in your case isapp/javascript
.You have a few options to reference an outside file:
~/../assets
: 👎 harder to understandvite.config.ts
✅I'd recommend adding an alias in your
vite.config.ts
:There is a very similar alias being used in this example setup.
…