shoelace and vite

adding static assets

Published March 25, 2024

shoelace, vite
Contents

Adding shoelace asssets to vite:

1
  npm i @shoelace-style/shoelace vite-plugin-static-copy vite

Add "type": "module" into package.json

Then in your main.js:

1
  import '@shoelace-style/shoelace';

And create vite.config.js:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
  import { defineConfig } from 'vite';
  import { viteStaticCopy } from 'vite-plugin-static-copy';

  const iconsPath = 'node_modules/@shoelace-style/shoelace/dist/assets/icons';

  // https://vitejs.dev/config/
  export default defineConfig({
    resolve: {
      alias: [
        {
          find: /\/assets\/icons\/(.+)/,
          replacement: `${iconsPath}/$1`,
        },
      ],
    },
    build: {
      rollupOptions: {
        // external: /^lit/,
        plugins: [],
      },
    },
    plugins: [
      viteStaticCopy({
        targets: [
          {
            src: iconsPath,
            dest: 'assets',
          },
        ],
      }),
    ],
  });

Previously

Playing with openrouteservice-js learning about mapping

2024-03-25

Next

Discovering idagio

2024-03-26

labnotes

Previously

Playing with openrouteservice-js learning about mapping

2024-03-25

Next

Deploying static vite site on fly silly silly

2024-03-26