-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
vector tiles in Leaflet with Vite fails #152
Comments
Hi @ndrean! We are sorry to hear that. I understand that you use:
Could you please share also your devDependencies versions? BTW. Adding |
@sebstryczek Thanks for your response. I indeed think that my config is the problem, not your package. However, except when calling You understand it is difficult to prepare a minimal example as you might not be able to run it as you probably don't have My package.json:{
"name": "assets",
"version": "1.0.0",
"description": "",
"main": "app.js",
"type": "module",
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"@maptiler/leaflet-maptilersdk": "^4.0.2",
"@maptiler/sdk": "^3.0.1",
"leaflet": "^1.9.4",
"phoenix": "file:../deps/phoenix",
"phoenix_html": "file:../deps/phoenix_html",
"phoenix_live_view": "file:../deps/phoenix_live_view",
"solid": "link:virtual:pwa-register/solid",
"solid-js": "^1.9.3",
"workbox-routing": "^7.3.0",
"workbox-strategies": "^7.3.0",
"workbox-window": "^7.3.0",
"y-indexeddb": "^9.0.12",
"yjs": "^13.6.21"
},
"devDependencies": {
"@tailwindcss/forms": "^0.5.9",
"autoprefixer": "^10.4.20",
"esbuild": "^0.24.2",
"esbuild-plugin-solid": "^0.6.0",
"postcss": "^8.4.49",
"tailwindcss": "^3.4.17",
"vite": "^6.0.5",
"vite-plugin-pwa": "^0.21.1",
"vite-plugin-solid": "^2.11.0",
"vite-plugin-wasm": "^3.4.1",
"workbox-precaching": "^7.3.0"
},
} Not sure if this helps, but here is my Vite config: My Vite configimport { VitePWA } from "vite-plugin-pwa";
import { defineConfig, loadEnv } from "vite";
import solidPlugin from "vite-plugin-solid";
import tailwindcss from "tailwindcss";
import autoprefixer from "autoprefixer";
import wasm from "vite-plugin-wasm";
import path from "path";
import tailwindcss from "@tailwindcss/vite";
const manifestOpts = {...}
const buildOps = {
outDir: "../priv/static/",
emptyOutDir: false,
target: ["esnext"],
manifest: false,
rollupOptions: {
input: [
"js/app.js",
...
],
output: {
assetFileNames: "assets/[name][extname]",
chunkFileNames: "assets/[name].js",
entryFileNames: "assets/[name].js",
},
},
commonjsOptions: {
exclude: [],
include: ["vendor/topbar.cjs"],
},
};
const devOps = {
enabled: true,
type: "module",
};
const PWAOpts = {
devOptions: devOps,
registerType: "autoUpdate",
filename: "sw.js",
strategies: "generateSW",
includeAssets: ["favicon.ico", "robots.txt"],
manifest: manifestOpts,
outDir: "../priv/static/",
manifestFilename: "manifest.webmanifest",
injectRegister: "auto", // Automatically inject the SW registration script
injectManifest: {
injectionPoint: undefined,
},
workbox: {
// navigationPreload: true, // <----???
globDirectory: path.resolve(__dirname, "../priv/static/"),
globPatterns: [
"assets/**/*.{js,jsx,css,ico, wasm}",
"images/**/*.{png,jpg,svg,webp}",
],
swDest: "../priv/static/sw.js",
navigateFallback: null, // Do not fallback to index.html !!!!!!!!!
inlineWorkboxRuntime: true, // Inline the Workbox runtime into the service worker. You can't serve timestamped URLs with Phoenix
additionalManifestEntries: [
{ url: "/", revision: null },
{ url: "/map", revision: null },
],
runtimeCaching: [...],
clientsClaim: true, // take control of all open pages as soon as the service worker activates
skipWaiting: true, // New service worker versions activate immediately
// Without these settings, you might have some pages using old service worker versions
// while others use new ones, which could lead to inconsistent behavior in your offline capabilities.
},
};
const CSSSOpts = {
postcss: {
plugins: [tailwindcss, autoprefixer],
},
};
export default defineConfig(({ command, mode }) => {
const env = loadEnv(mode, process.cwd(), "");
if (command != "build") {
process.stdin.on("close", () => {
process.exit(0);
});
process.stdin.resume();
}
return {
base: "/",
plugins: [wasm(), solidPlugin(), VitePWA(PWAOpts)],
resolve: {
extensions: [".mjs", ".js", ".ts", ".jsx", ".tsx", ".json", "wasm"],
},
publicDir: false,
build: buildOps,
css: CSSSOpts,
define: {
__APP_ENV__: env.APP_ENV,
},
};
}); |
Hey @ndrean! Thank you for your response! So, I think, the issue is caused by:
If I set So this should work:
This is because we externalised the |
I use https://docs.maptiler.com/leaflet/examples/vector-tiles-in-leaflet-js/
My package.json:
I use
Vite
:I tried:
This does not compile, fails with:
The text was updated successfully, but these errors were encountered: