You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Trying to get the Svelte Language Server set up in VS Code for the first time, onboarding could have been smoother. I wanted to use TS and SCSS, so I followed the docs:
Each of these pages mentioned a need for a svelte.config.js. It wasn't clear whether the svelte.config.js config needed to be written any differently from that of the Svelte Rollup Plugin in rollup.config.js (especially with respect to the production variable).
My understanding from @dummdidumm on Discord is that the Svelte Language Server is only (currently) interested in the preprocess export from svelte.config.js, so there's no need to write the whole config for the Svelte Rollup Plugin in there.
So I've gone with the following inheritance pattern. svelte.config.js exports both an instance of sveltePreprocess for consumption by Svelte Language Server, and also the base config for it (preprocessOptions) so that we can extend it when we create another sveltePreprocess instance in rollup.config.js:
svelte.config.js
constsveltePreprocess=require('svelte-preprocess');constpreprocessOptions={sourceMap: true,// "you would always want sourcemaps for the IDE" – dummdidummdefaults: {script: "typescript",style: "scss",},scss: {prependData: `@import 'src/styles/_variables.scss';`},postcss: {plugins: [require('autoprefixer')()]}};module.exports={preprocess: sveltePreprocess(preprocessOptions),// Export this to allow rollup.config.js to inherit the same preprocess options.
preprocessOptions,}
rollup.config.js
// ...constpreprocessOptions=require("./svelte.config").preprocessOptions;constproduction=!process.env.ROLLUP_WATCH;exportdefault{// ...plugins: [// ...svelte({// enable run-time checks when not in productiondev: !production,// we'll extract any component CSS out into// a separate file - better for performancecss: css=>{css.write('public/build/bundle.css');},preprocess: sveltePreprocess({
...preprocessOptions,sourceMap: !production,}),}),// ...],};
There may be a better way to solve this (e.g. if the sveltePreprocess instance had a getter for the config), but it's one potential way.
Related discussion about how rollup.config.js and svelte.config.js should relate to each other: sveltejs/svelte#1101
The text was updated successfully, but these errors were encountered:
Uh oh!
There was an error while loading. Please reload this page.
Trying to get the Svelte Language Server set up in VS Code for the first time, onboarding could have been smoother. I wanted to use TS and SCSS, so I followed the docs:
Each of these pages mentioned a need for a
svelte.config.js
. It wasn't clear whether thesvelte.config.js
config needed to be written any differently from that of the Svelte Rollup Plugin inrollup.config.js
(especially with respect to theproduction
variable).My understanding from @dummdidumm on Discord is that the Svelte Language Server is only (currently) interested in the
preprocess
export fromsvelte.config.js
, so there's no need to write the whole config for the Svelte Rollup Plugin in there.So I've gone with the following inheritance pattern.
svelte.config.js
exports both an instance ofsveltePreprocess
for consumption by Svelte Language Server, and also the base config for it (preprocessOptions
) so that we can extend it when we create anothersveltePreprocess
instance inrollup.config.js
:svelte.config.js
rollup.config.js
There may be a better way to solve this (e.g. if the
sveltePreprocess
instance had a getter for the config), but it's one potential way.Related discussion about how
rollup.config.js
andsvelte.config.js
should relate to each other: sveltejs/svelte#1101The text was updated successfully, but these errors were encountered: