-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
svelte.config.js #1101
Comments
@Rich-Harris I've been trying to hold off on config files for as long as possible with prettier but the result was that all the tools that were built on-top of prettier built their own incompatible way of dealing with prettier options. So this was a net negative. cosmiconfig is a really nice tool to deal with reading the config in all the possible places and format. |
👍 to |
Oh wow, cosmiconfig is really helpful to know about, thank you @vjeux! Hadn't come across it before. |
On the fence, but if it simplifies the svelte-loader code, I would say sure why not. |
Officially supporting a config file - whatever it is named - might simplify every bundler integration since it removes the need of providing the config via each particular bundler, with the downside of having to provide that additional config file in case the defaults do not match to the particular requirements. Just a note: While |
There should be a single config file with keys for server, client, compilerOptions, serviceWorker etc. |
Going to need something like this for the language server I'm working on. Would be great to standardise this sooner rather than later |
Btw, svelte-language-server is using cosmiconfig to load config for svelte |
I'm a fan of (@UnwrittenFun thanks for the vscode extension!) |
Hi! So, what’s in the end an official way to provide shared config? |
bump. dummdidumm suggested the following structure {
compilerOptions: {...svelte's compiler options},
...anythingelse
} I think it would be great to have a common configuration for different tools in the svelte ecosystem. |
There's also an RFC for a |
Both It should be noted that
|
I'd like to suggest further improvements that make |
I regret not paying closer attention to this issue; the lack of a clear signal from the Svelte core team has allowed divergent interpretations of svelte.config.js to arise in the ecosystem. For example the Parcel plugin expects this... module.exports = {
preprocess: {...},
compiler: {...}
}; ...while the Snowpack plugin expects this: module.exports = {
preprocess: {...},
...compilerOptions // note the `...`
}; These are mutually incompatible. (This is exactly the situation @vjeux warned us about in 2018!) @dominikg and @dummdidumm had the right idea: module.exports = {
preprocess: {...},
compilerOptions: {...},
...otherStuff
}; The importance of I'd strongly urge third-party integrations that use svelte.config.js to adopt this signature, though I don't know who to cc (other than @DeMoorJasper of the Parcel plugin), as I don't know the extent of who is currently using it. (Note to the Parcel plugin team: I would argue that Will leave this issue open until we've had a chance to document this stuff. |
Great to see this is being picked up. couple of points for documentation/future discussion
|
@Rich-Harris thanks for coming up with a somewhat standardised config signature, I've updated the Parcel 1 plugin to use this new signature DeMoorJasper/parcel-plugin-svelte#151 also created an issue in the Parcel 2 plugin to update this as well. Left out the |
Another candidate for addtion to "otherStuff" could be the defaultLanguages currently exported by svelte-preprocess @kaisermann @dummdidumm |
I like formalizing a way to define the default languages, but as it's completely related to the preprocessing step, wouldn't it be a bit weird to have it as an adjacent property? module.exports = {
preprocess: [...],
defaultLanguages: { ... },
compilerOptions: { ... }
} Also, should we have an easy way to get the contents of a const defaultLanguages = { ... }
module.exports = {
preprocess: [sveltePreprocess({ defaults: defaultLanguages })],
defaultLanguages,
compilerOptions: { ... }
} Note: |
I think having it inside Side note: I'm not so confident in default languages anymore since I don't know if all the tools can deal with it: How to tell the prettier CLI about that? How to get syntax highlighting to work with it (as far as I know the syntax JSON is static)? (Discussion about this topic should probably be done somewhere else and not this ticket) |
This exists now: https://kit.svelte.dev/docs#configuration |
I'm very confused... I'm just trying to disable source maps on production but I've looked at many outdated docs or issues, and can't wrap my head around all those config files or how they interact with each other. |
Please ask this type of question on Discord and not on an issue that's been closed for a long time. Rollup should not be used in anyway in SvelteKit projects |
sorry 😬! |
Just spotted this issue: DeMoorJasper/parcel-plugin-svelte#6
I'm not wild about the idea of introducing another config file into people's projects, but if folks are going to start doing it, then there should probably be a canonical, officially supported form.
(This, incidentally, is why the current 'zero-config' marketing fad is such nonsense: it really means 'abdicate the responsibility for config'. Instead of a single place where you can view all the build config in a structured, coherent form, you have the exact same amount of config but scattered around your project in lots of annoying files that are harder to understand.)
Other plugins like rollup-plugin-svelte and svelte-loader — and the CLI — could also load svelte.config.js. (We'd have to figure out the semantics — do the options in rollup.config.js or webpack.config.js override svelte.config.js, or extend them? Also, what happens if you have svelte.client.config.js and svelte.server.config.js? How do you reference them?)
Clearly this introduces some regrettable complexity. One advantage we'd get in return would be that documentation becomes clearer — rather than explaining 'oh, you need to add this to the option you pass to rollup-plugin-svelte, or maybe svelte-loader, or...' we can just say 'this is what you put in your config file'.
Is this the zero-config tail wagging the dog? Or would this be a worthwhile addition?
The text was updated successfully, but these errors were encountered: