如何使用 Browserify 构建 mapbox-gl.js?

How can I build mapbox-gl.js with Browserify?

如果我 git 克隆存储库(来自 mapbox-gl.js repo),我如何构建我自己的独立版本的文件?

我只需要独立的 mapbox-gl.js,比如 this one

一个简单的browserify js/mapbox-gl.js -o dist/mapbox-gl.js行不通。

要创建独立文件,运行 npm run build 在 repo 的根目录中。

我刚刚添加了一个关于这个主题的section to the mapbox-gl-js readme

Creating a Standalone Build

A standalone build allows you to turn the contents of this repository into mapbox-gl.js and mapbox-gl.css files that can be included on an html page.

To create a standalone build, run bash npm run production

Once that command finishes, you will have a standalone build at dist/mapbox-gl.js and dist/mapbox-gl.css

希望对您有所帮助!如果您有任何后续问题,请告诉我。