Created
January 24, 2024 16:54
-
-
Save ZachSaucier/30ff2764a1b2aacfb244ccc2dc6e77d5 to your computer and use it in GitHub Desktop.
Multiple sites in one Svelte project in order to share components
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// apps/website-1/svelte.config.js | |
import { createSvelteConfig } from 'config/svelte.js' | |
import adapter from '@sveltejs/adapter-cloudflare' | |
export default createSvelteConfig({ | |
adapter: adapter(), | |
alias: { | |
$sections: 'src/sections', | |
}, | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// packages/config/svelte.js | |
import { resolve, join } from 'path' | |
import { fileURLToPath } from 'url' | |
import preprocess from 'svelte-preprocess' | |
const stylesPath = `${resolve(fileURLToPath(import.meta.url), '../../../packages/styles')}` | |
export const scssImports = `@use "${join(stylesPath, 'imports.scss')}" as *;` | |
/** @type {import('@sveltejs/kit').Config} */ | |
export const createSvelteConfig = ({ adapter, kit, alias, ...rest }) => { | |
return { | |
// Preprocessors docs: https://github.com/sveltejs/svelte-preprocess | |
preprocess: preprocess({ | |
scss: { | |
prependData: scssImports, | |
} | |
}), | |
kit: { | |
adapter, | |
alias: { | |
$components: 'src/components', | |
$animations: 'src/animations', | |
$utils: 'src/utils', | |
$styles: 'src/styles', | |
...alias, | |
}, | |
prerender: { | |
handleMissingId: 'ignore', | |
}, | |
inlineStyleThreshold: 4096, | |
...kit, | |
}, | |
...rest, | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment