-
-
Notifications
You must be signed in to change notification settings - Fork 202
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
Glob pattern support for different Svelte files in svelte.config.js
#410
Comments
I'm a little against this. Doing this might want to have people even more options for filtering. Also, you can already do the same with preprocessors as they are now. const preprocessor = {
markup: ({filename, content}) => {
if (isInPathX(filename)) {
return vanillaPreprocess.markup(..)
} else ...
, ...
} |
For pre-processing, your suggestion addresses some of my needs. However, for the That said, if everyone has their own way of including and excluding, and pre-processing files then tools can't make predictable assumptions about your config setup. For example, @dominikg just assumes the typescript preprocessor is the first one, which would fail if I used your suggested filtering method. We need to standardize how we tell Svelte tools where to find our typescript files, web components and whatever pre-processable next language/tool will be. Improvements to my suggestion are welcome, but I don't think having varied implementations for config is the solution. See Rich Harris' comment on svelte.config.js. Where people asking for filtering (and other options) is concerned, we should just address them on a case by case basis. As rule of thumb though, I suggest mostly preferring options that are widely implemented in other bundlers and configs —such as filtering based on filename/extension. Edit: Svench is another example of a tool using |
Another caveat worth discussion is that Svite, for example, only respects the Having different |
I think sveltejs/svelte#1101 (or a separate issue on sveltejs/svelte) is a better place to have this discussion as both language-tools and svite are consumers of svelte.config.js Personal opinion: This is a very complicated feature and should only be pursued if this is of general interest to the community. From what i understand it boils down to the ability of having multiple named configs, either via separate files or as an array/map in svelte.config.js to be able to process subsets of a project with different svelte configs. Regarding svite only reading svelte.config.js from cwd: Svite used to use cosmiconfig, but cosmiconfig also reads from package.json "svelte" key by default which is used for something different in svelte-land. To avoid errors and get rid of the dependency I removed that feature. |
Closing this because @dominikg is right, this should be discussed in the original issue. |
Is your feature request related to a problem? Please describe.
Currently, the svelte.config.js assumes one config for your entire directory. However, I'd like to have some Typescript, Web Component and Vanilla-Svelte™ files in the same directory.
If I use config for TS only, I get warnings outside of TS Svelte, and
<svelte:option tag/>
warnings for web components and vice versa.For rollup, I use a config that looks like this using
exclude
&include
:Describe the solution you'd like
I'd like to be able to use different pre-process options for different glob patterns
Describe alternatives you've considered
Store files in a different directory based on compile target/pre-process needs. However, this is an anti-pattern. For example, I might have a web component with regular Svelte components as children using the above pattern. Storing strongly related files separately is not preferred.
Additional context
This is particularly helpful for using the
exclude
&&include
pattern in other tools like Svite that depend onsvelte.config.js
for configuration.The text was updated successfully, but these errors were encountered: