How to specify what will be the export build js and css filenames in svelte

Viewed 116

I am using vite for svelte, I have attached vite.config.js below, I tried looking for references on the web but couldn't find any

import { defineConfig } from 'vite'
import { svelte } from '@sveltejs/vite-plugin-svelte'

// https://vitejs.dev/config/
export default defineConfig({
  server: {
    port: 4000
  },
  preview: {
    port: 4000
  },
  plugins: [
    svelte({
      compilerOptions: {
        customElement: true,
      }
    }),
  ]})

enter image description here

1 Answers

There are options for that under build > rollupOptions, e.g.

export default defineConfig({
    build: {
        rollupOptions: {
            output: {
                entryFileNames: '[name].js',
                assetFileNames: '[name].[ext]',
            },
        },
    },
    plugins: [
        svelte(),
    ],
});
Related