In the 4.7 release, it was good news not only to increase the rendering support for WEBGL (rendering front-end speed and rendering volume), to enhance promises syntax support in ES6, but also to support NPM management and webpack packaging.
"means that you can introduce JSAPI without esri-loader This package," said--arcgis.
Currently not yet adjourned
1. Preface
If you want to organize your ArcGIS API for JavaScript project locally, you can use NPM, the current hot front-end JS package management tool, to manage the API in your project starting with 4.7.
Previously, ESRI was recommended to use Bower as the package management tool, and it is now recommended that NPM be used, although it is still possible to use bower, but it is recommended to use NPM.
In advance, you may need to install:
- node. js
- Git
- Grunt
- Java version 7 or later
In fact, you just need to install node. js. The other three can be installed as needed.
2. How to Install
One line of code
NPM Install Arcgis-js-api-Save or NPM install ArcGIS-js-API or NPM i ArcGIS-js-api
If the download is complete, the folder list should appear in the Node_modules folder:
3. Configuration
The following is the code for configuring Dojoconfig.
//Create or use existing global dojoconfigvarDojoconfig = This. dojoconfig | | {};(function() { varConfig =Dojoconfig; //Set default Properties if(!config.hasownproperty ("Async") ) {Config.async=true; } //Add packages for Libs that is not siblings to dojo(function() { varPackages = Config.packages | | []; functionaddpkgifnotpresent (newpackage) { for(vari = 0; i < packages.length; i++) { varpkg =Packages[i]; if(Pkg.name = = =newpackage.name) {return; }} packages.push (Newpackage); } addpkgifnotpresent ({name:"App", Location:"./.. /.. /src/app " }); Addpkgifnotpresent ({name:"Esri", Location:".. /arcgis-js-api " }); Addpkgifnotpresent ({name:"@dojo", Location:".. /@dojo " }); Addpkgifnotpresent ({name:"Cldrjs", Location:".. /cldrjs ", Main:"Dist/cldr" }); Addpkgifnotpresent ({name:"Globalize", Location:".. /globalize ", Main:"Dist/globalize" }); Addpkgifnotpresent ({name:"Maquette", Location:".. /maquette ", Main:"DIST/MAQUETTE.UMD" }); Addpkgifnotpresent ({name:"Maquette-css-transitions", Location:".. /maquette-css-transitions ", Main:"DIST/MAQUETTE-CSS-TRANSITIONS.UMD" }); Addpkgifnotpresent ({name:"Maquette-jsx", Location:".. /maquette-jsx ", Main:"DIST/MAQUETTE-JSX.UMD" }); Addpkgifnotpresent ({name:"Tslib", Location:".. /tslib ", Main:"Tslib" }); Config.packages=packages; })(); //Configure Map.globalize varMap = Config.map | | {}; if(!map.globalize) {map.globalize= { "Cldr": "Cldrjs/dist/cldr", "Cldr/event": "Cldrjs/dist/cldr/event", "Cldr/supplemental": "Cldrjs/dist/cldr/supplemental", "Cldr/unresolved": "Cldrjs/dist/cldr/unresolved" }; Config.map=map; }})();
Configure Dojoconfig
ArcGIS API for JavaScript 4.x and NPM