-
-
Notifications
You must be signed in to change notification settings - Fork 109
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
Compilation issues when using different root directory #23
Comments
the issue is caused by the fact that vite-plugin-svelte currently reads svelte.config.cjs from vites root directory
So for svelte to have the typescript preprocessor working you'd have to move that config into src aswell or pass it inline in vite config. Regarding svelte config location i'd love to get feedback what the best option would be for your usecase. |
This was a existing project that i tried migrating into vite, hence the ts template. About the use case, i'm not really sure if i'm the guy to listen too - i'm mainly a backend developer, and pretty new to this whole frontend world. That being said: i dislike the way most frontend projects pollute the root directory. Mixing compiler configurations in the same directory as the initial page seems counter-intuitive to me. Vite configurations ( publicDir, outDir) seem to specify these directory in terms relative to the root. Maybe the plugin could follow, taking root-relative path as configuration parameters? Since most people seem to use default configurations without second thought, i'm not exactly sure if such a change would be impactful for the "general population" Even so, it may be interesting to have in mind the public / demographic the project aims to cater to? Personally, i considered many frameworks before picking svelte, for it was: small, performant, concise, configurable. |
I am facing a similar regression. I recently upgraded my package from @svitejs/vite-plugin-svelte to this repo. Now when I run
My vite.config.js is as follows
I don't have |
[email protected] added a new option either relative to vite root: Does that solve your problems when using "src" as vite root? |
Thanks @dominikg. This is working with both inline options as well as Just checking if it supports svelte config as a |
no, svelte.config.ts is not supported right now. |
closing here as the original issue can be solved with relative configFile option added in 1.0.0-next.8: |
Description
When using typescript and specifying a different root directory via vite.config.js , compilation issues arise .
Reproduction
1 - In the provided zip, start the server, which behaves as expected. I'm running the command
yarn run dev
2 - Move the index.html inside another directory, changing the root directory inside vite.config.js accordingly -> At this point, the server starts up and displays only plain html, which is to be expected, since it couldn't find the script.
3 - Update the 'src' property inside the index to correctly point to the main.ts module. At this point, i'm getting a unexpected token exception. Its interesting to note that the server does starts, and the error occurs only when accessing the url.
Additional Information
Initially, i thought it had something to do with the tsconfig.json properties or path, but after changing compilerOptions, and moving the file around ( specifying its path with the tsconfigFile property inside svelte.config.js , i could not reproduce the issue.
The vite-plugin ( not included in the zip ) was installed following the directives in this repo readme.md.
envinfo.txt
canelhasio.zip
The text was updated successfully, but these errors were encountered: