labnotes

shoelace and vite

adding static assets

tags
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

labnotes

Playing with openrouteservice-js

learning about mapping

tags
leaflet
openrouteservice
openstreetmap

Next

fragments

Discovering idagio

tags