[Vuejs]-Can i import a variable from a geojson file with Vue 3 and Vite?

0👍

solution1: https://github.com/vitejs/vite/blob/2d9008e81d0d835e10437a959fac12529f7823e1/packages/vite/rollup.config.ts#L138 vite internally use @rollup/plugin-json to resolve json file. you can install the plugin and add your options to support the geojson file. maybe the include params is what you want https://github.com/rollup/plugins/blob/master/packages/json/README.md

(recommended)solution2:

import j from "@/assets/a.geojson?raw";
console.log(JSON.parse(j));

Leave a comment