如何从GitHub源代码构建leaflet.markcluster.js

How to build leaflet.markercluster.js from GitHub source?

本文关键字:leaflet markcluster js 构建 源代码 GitHub      更新时间:2023-09-26

我想从GitHub项目构建leaflet.markercluster的编译javascript代码。我是编程新手,只想学习如何做到这一点。我的理解是package.json可以使用grunt.js运行,但我发现GitHub源代码中没有gruntfile.js。

我使用bower install leaflet.markercluster下载了该项目,该项目显示在bower_components/ 中的本地项目文件夹中

bower_components/leaflet.markercluster/中的package.json

{
    "name": "leaflet.markercluster",
    "version": "0.4.0",
    "description": "Provides Beautiful Animated Marker Clustering functionality for Leaflet",
    "dependencies": {
        "leaflet": "~0.7.1"
    },
    "devDependencies": {
        "jshint": "~2.1.3",
        "mocha": "~1.10.0",
        "karma": "~0.8.5",
        "uglify-js": "~2.3.6",
        "jake": "~0.5.16"
    },
    "main": "dist/leaflet.markercluster.js",
    "scripts": {
        "test": "jake test",
        "prepublish": "jake"
    },
    "keywords": ["gis", "map"]
} 

如何运行package.json来构建dist/leaflet.markcluster.js?

package.json代表npm(节点包管理器,Chris添加的标签),而不是Grunt。

您可以按照以下步骤操作:

1) 安装Node.js(可能在使用Bower后就已经完成了)

2) 安装Git(可能在使用Bower后就已经完成了)

3) 将存储库克隆到您的本地驱动器上:git clone <git endpoint>(在您的案例中为传单.markcluster:git clone https://github.com/Leaflet/Leaflet.markercluster.git)<也许bower install是等价的>。

4) 导航到本地驱动器上新创建的Leaflet.markercluster文件夹。

5) 运行npm install。新建的编译和缩小的JS文件应该出现在"dist"子文件夹中。请注意,您仍然需要一个Internet连接,因为npm将在运行此命令时下载所有依赖项和开发依赖项。