Polish and Format rollup config for svelte5

This commit is contained in:
Christoph Kluge 2025-05-14 11:41:11 +02:00
parent be7ccc78b8
commit 7603ad3fb0

View File

@ -6,15 +6,20 @@ import terser from '@rollup/plugin-terser';
import css from 'rollup-plugin-css-only'; import css from 'rollup-plugin-css-only';
const production = !process.env.ROLLUP_WATCH; const production = !process.env.ROLLUP_WATCH;
// const production = false
const plugins = [ const plugins = [
svelte({ svelte({
compilerOptions: { compilerOptions: {
// enable run-time checks when not in production // Enable run-time checks when not in production
dev: !production, dev: !production,
// Enable Svelte 5-specific features
hydratable: true, // If using server-side rendering
immutable: true, // Optimize updates for immutable data
// As of sveltestrap 7.1.0, filtered warnings would appear for imported sveltestrap components // As of sveltestrap 7.1.0, filtered warnings would appear for imported sveltestrap components
warningFilter: (warning) => (warning.code !== 'element_invalid_self_closing_tag' && warning.code !== 'a11y_interactive_supports_focus') warningFilter: (warning) => (
warning.code !== 'element_invalid_self_closing_tag' &&
warning.code !== 'a11y_interactive_supports_focus'
)
} }
}), }),
@ -25,7 +30,7 @@ const plugins = [
// https://github.com/rollup/plugins/tree/master/packages/commonjs // https://github.com/rollup/plugins/tree/master/packages/commonjs
resolve({ resolve({
browser: true, browser: true,
dedupe: ['svelte'] dedupe: ['svelte', '@sveltejs/kit'] // Ensure deduplication for Svelte 5
}), }),
commonjs(), commonjs(),
@ -34,8 +39,10 @@ const plugins = [
production && terser(), production && terser(),
replace({ replace({
"process.env.NODE_ENV": JSON.stringify("development"), preventAssignment: true,
preventAssignment: true values: {
"process.env.NODE_ENV": JSON.stringify(production ? "production" : "development"),
}
}) })
]; ];