Created
February 11, 2022 15:43
-
-
Save enyo/3a583f30cd27e6a007e53bd0c71d2acb to your computer and use it in GitHub Desktop.
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
import commonjs from '@rollup/plugin-commonjs' | |
import resolve from '@rollup/plugin-node-resolve' | |
import typescript from '@rollup/plugin-typescript' | |
import svelte from 'rollup-plugin-svelte' | |
import { terser } from 'rollup-plugin-terser' | |
import sveltePreprocess from 'svelte-preprocess' | |
const production = !process.env.ROLLUP_WATCH | |
export default { | |
// The file we created with our web component wrapper. | |
input: 'web-components.ts', | |
output: { | |
sourcemap: !production, | |
format: 'iife', | |
name: 'app', | |
// We output it to public. This way, our svelte kit | |
// app will also host the web components. | |
file: 'public/web-components.js', | |
}, | |
// Normal rollup svelte configuration. Nothing fancy | |
// happening here. | |
plugins: [ | |
typescript(), | |
svelte({ | |
preprocess: sveltePreprocess({ | |
sourceMap: !production, | |
postcss: true, | |
}), | |
// We just make sure that no global CSS is injeced | |
// into the page that imports this script. | |
emitCss: false, | |
compilerOptions: { | |
dev: !production, | |
// customElement: true, | |
}, | |
}), | |
resolve(), | |
commonjs(), | |
// Minify the production build (npm run build) | |
production && terser(), | |
], | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Do you have a repo where I can see how the entire folder structure looks like for using svelte components as web components? Where does this rollup.config.js file goes and how is it being used? There needs to be some setup in svelte.config that says "use this rollup as well", no?