Skip to content

Commit

Permalink
fix: let vite handle the leaflet asset copying
Browse files Browse the repository at this point in the history
  • Loading branch information
nobkd committed Mar 31, 2023
1 parent e3aefdd commit 20f3bbc
Show file tree
Hide file tree
Showing 3 changed files with 242 additions and 7 deletions.
220 changes: 220 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,10 @@
},
"scripts": {
"icons": "svgexport icons/plain.svg public/icons/48.png 48:48 && svgexport icons/plain.svg public/icons/96.png 96:96",
"leaflet": "cp node_modules/leaflet/dist/leaflet.css public/leaflet.css && cp -r node_modules/leaflet/dist/images public",
"format": "prettier . --write",
"build": "nr leaflet && tsc && vite build",
"watch": "nr leaflet && vite build --watch --mode development --minify false",
"dev": "nr leaflet && vite",
"build": "tsc && vite build",
"watch": "vite build --watch --mode development --minify false",
"dev": "vite",
"serve:firefox": "web-ext run -s .dist",
"serve:chrome": "web-ext run -t chromium -s .dist",
"bundle": "nr build && web-ext build -s .dist -a .out"
Expand All @@ -32,6 +31,7 @@
"prettier": "^2.8.7",
"typescript": "^5.0.2",
"vite": "^4.2.1",
"vite-plugin-static-copy": "^0.13.1",
"web-ext": "^7.6.0",
"webextension-polyfill": "^0.10.0"
},
Expand Down
21 changes: 18 additions & 3 deletions vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,31 @@
import { defineConfig } from 'vite';
import { defineConfig, normalizePath } from 'vite';
import { viteStaticCopy } from 'vite-plugin-static-copy';
import { resolve } from 'path';

export default defineConfig({
root: 'src',
publicDir: '../public',
plugins: [
viteStaticCopy({
targets: [
{
src: normalizePath(resolve(__dirname, 'node_modules/leaflet/dist/leaflet.css')),
dest: '.',
},
{
src: normalizePath(resolve(__dirname, 'node_modules/leaflet/dist/images')),
dest: '.',
},
],
}),
],
build: {
outDir: '../.dist',
emptyOutDir: true,
rollupOptions: {
input: {
bg: resolve(__dirname, 'src/bg.html'),
map: resolve(__dirname, 'src/map.html'),
bg: normalizePath(resolve(__dirname, 'src/bg.html')),
map: normalizePath(resolve(__dirname, 'src/map.html')),
},
},
},
Expand Down

0 comments on commit 20f3bbc

Please sign in to comment.