一、leaflet源码编译
1、安装cnpm
npm install -g --registry=https://registry.npm.taobao.org cnpm
2、使用cnpm安装所需模块
cnpm install rollup rollup-plugin-git-version rollup-plugin-json git-rev-sync
cnpm install -g uglify-js
3、编译
npm run build
4、说明
编译过程将使用rollup进行代码的打包,使用uglifyjs进行代码的混淆和压缩,编译的文件将输出到dist下
leaflet-src.js 源码打包文件
leaflet-src.esm.js 源码打包文件,esm即为EcmaScript Module其支持import from
leaflet.js 对源码打包文件进行混淆压缩后的文件
*.js.map JavaScript Source Map文件,参见:http://www.ruanyifeng.com/blog/2013/01/javascript_source_map.html
二、leaflet.draw源码编译
1、安裝cnpm
npm install -g --registry=https://registry.npm.taobao.org cnpm
2、使用cnpm安装所需模块
cnpm install jake uglify-js@2.8.29 uglifycss source-map git-rev
3、编译
npm run build
4、说明
安装uglify-js时应指定安装版本为2.8.29,使用最新版的uglify-js将导致错误,错误内容为“error: DefaultsError: `fromString` is not a supported option”
编译过程将使用jake进行代码的打包,使用uglifyjs进行代码混淆和压缩,使用和uglifycss进行样式文件的压缩,编译的文件将输出到dist下
leaflet.draw-src.js 源码打包文件
leaflet.draw-src.css 样式打包文件
leaflet.draw.js 对源码打包文件进行混淆压缩后的文件
leaflet.draw.css 对样式打包文件进行压缩后的文件
*.js.map JavaScript Source Map文件,参见:http://www.ruanyifeng.com/blog/2013/01/javascript_source_map.html
三、leaflet.toolbar源码编译
1、安裝cnpm
npm install -g --registry=https://registry.npm.taobao.org cnpm
2、使用cnpm安装所需模块
cnpm install -g grunt
cnpm install matchdep
cnpm install grunt grunt-autoprefixer grunt-bump grunt-contrib-clean grunt-contrib-coffee grunt-contrib-concat grunt-contrib-cssmin grunt-contrib-jshint
cnpm install grunt-contrib-less grunt-contrib-nodeunit grunt-contrib-uglify grunt-contrib-watch grunt-contrib-connect grunt-gh-pages grunt-mocha grunt-karma
cnpm install karma karma-mocha karma-phantomjs-launcher karma-chrome-launcher karma-firefox-launcher karma-safari-launcher karma-mocha-reporter karma-coverage
cnpm install leaflet chai sinon@1.10.3
3、编译
打开终端执行:grunt default,再打开一个终端执行:grunt build:js
打开终端执行:grunt test 执行测试代码
4、说明
grunt 编译工具:https://www.gruntjs.net/
四、leaflet-draw-toolbar源码编译
1、安裝cnpm
npm install -g --registry=https://registry.npm.taobao.org cnpm
2、使用cnpm安装所需模块
cnpm install -g grunt
cnpm install matchdep
cnpm install grunt grunt-autoprefixer grunt-bump grunt-contrib-clean grunt-contrib-coffee grunt-contrib-concat grunt-contrib-cssmin grunt-contrib-jshint
cnpm install grunt-contrib-less grunt-contrib-nodeunit grunt-contrib-uglify grunt-contrib-watch grunt-contrib-connect grunt-contrib-copy grunt-gh-pages grunt-mocha grunt-karma
cnpm install karma karma-mocha karma-phantomjs-launcher karma-chrome-launcher karma-firefox-launcher karma-safari-launcher karma-mocha-reporter karma-coverage
cnpm install leaflet leaflet-draw leaflet-toolbar chai sinon@1.10.3
3、编译
打开终端执行:grunt default,再打开一个终端执行:grunt build:js
打开终端执行:grunt test 执行测试代码
4、说明
grunt 编译工具:https://www.gruntjs.net/