How can I compile each .svelte component into separate webcomponent .js file? for example DatePicker.svelte -> DatePicker.js FileUploadArea.svelte -> FileUploadArea.js
Thank you!
You can create the a new vite.split.config.js & use that in the build process & in the input array of rollupOptions you can define the svelte components paths you want to export. Then build with -c vite.split.config.js flag.
import {defineConfig} from 'vite';
import {svelte} from '@svelte.js/vite-plugin-svelte';
export default defineConfig({
build: {
rollupOptions: {
input: ['./src/lib/Button.svelte'],
}
},
plugins: [
svelte({
compilerOptions: {
customElement: true,
},
})
]
});
You can find more details on the Log Rocket Blog
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With