Vue put the map resource file in the static folder, but webpack packaged and put it into js.

the project needs json map data for the whole of China. I put the json file in the map file under the static folder.
then use

mapData = require("../../../../static/map/map/"+ self.division.divisionPid +".json");

introduce the json file. As a result, I looked at the file after packing and found that all the json files were packaged into the js file. (as shown below). Excuse me, why don"t you pack the files in?
clipboard.png

Apr.18,2022

get json files through the API, not through require. Through require, webpack will definitely collect dependent files.

for example, you can

$.getJSON('/static/map/map/a.json')

then configure nginx so that the / static/map/map path (this path can be configured at will, not necessarily the same as the folder structure) requests files under the static/map/map folder.

Menu