Skip to content

Instantly share code, notes, and snippets.

@ZachSaucier
Created January 24, 2024 16:54
Show Gist options
  • Save ZachSaucier/30ff2764a1b2aacfb244ccc2dc6e77d5 to your computer and use it in GitHub Desktop.
Save ZachSaucier/30ff2764a1b2aacfb244ccc2dc6e77d5 to your computer and use it in GitHub Desktop.
Multiple sites in one Svelte project in order to share components
// 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',
},
})
// 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