Search code examples
javascripttypescriptweb-componentvitelit-element

how to build and "Vite" "lit-ts" project as a static website


I created a project using Vite Lit Element Typescript. development server is working fine. however when I run npm run build .It only out put complied js file to /dist folder No html and css files.

So how can I get the full static files. just like we get in ReactJs.

sample Vite project link vite guide


Solution

  • That is because the lit-ts template for vite has a config that's building for library mode:

    export default defineConfig({
      build: {
        lib: {
          entry: 'src/my-element.ts',
          formats: ['es'],
        },
        rollupOptions: {
          external: /^lit/,
        },
      },
    })
    

    You can remove that config and the build command will produce all the assets in /dist directory.

    export default {}