Skip to content

Commit

Permalink
fix(vitePreprocess): default to build config so that svelte-check doe…
Browse files Browse the repository at this point in the history
…s not trigger dev-only plugins (#931)
  • Loading branch information
dominikg authored Jun 20, 2024
1 parent 9b2e834 commit c5253ae
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changeset/shiny-rocks-grow.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@sveltejs/vite-plugin-svelte': patch
---

fix(vitePreprocess): default to build config so that svelte-check does not trigger dev-only plugins
9 changes: 5 additions & 4 deletions packages/vite-plugin-svelte/src/preprocess.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,11 @@ async function createCssTransform(style, config) {
} else if (isResolvedConfig(config)) {
resolvedConfig = config;
} else {
resolvedConfig = await resolveConfig(
config,
process.env.NODE_ENV === 'production' ? 'build' : 'serve'
);
// default to "build" if no NODE_ENV is set to avoid running in dev mode for svelte-check etc.
const useBuild = !process.env.NODE_ENV || process.env.NODE_ENV === 'production';
const command = useBuild ? 'build' : 'serve';
const defaultMode = useBuild ? 'production' : 'development';
resolvedConfig = await resolveConfig(config, command, defaultMode, defaultMode, false);
}
return async (code, filename) => {
return preprocessCSS(code, filename, resolvedConfig);
Expand Down

0 comments on commit c5253ae

Please sign in to comment.