-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7514 from AnalyticalGraphicsInc/node-env
Use minified Cesium in Node.js unless NODE_ENV=development
- Loading branch information
Showing
4 changed files
with
44 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,37 @@ | ||
/*eslint-env node*/ | ||
/*eslint-env node,es6*/ | ||
'use strict'; | ||
|
||
var path = require('path'); | ||
var requirejs = require('requirejs'); | ||
|
||
//In explicit development mode, use un-optimized requirejs modules for improved error checking. | ||
if (process.env.NODE_ENV === 'development') { | ||
requirejs.config({ | ||
paths: { | ||
'Cesium': path.join(__dirname, 'Source') | ||
}, | ||
nodeRequire: require | ||
}); | ||
module.exports = requirejs('Cesium/Cesium'); | ||
return; | ||
} | ||
|
||
//In all other cases, use minified Cesium for performance. | ||
requirejs.config({ | ||
paths : { | ||
'Cesium' : path.join(__dirname, 'Source') | ||
}, | ||
nodeRequire : require | ||
}); | ||
paths: { | ||
'Cesium': path.join(__dirname, 'Build/Cesium/Cesium') | ||
}, | ||
nodeRequire: require | ||
}); | ||
|
||
const hadCesiumProperty = global.hasOwnProperty('Cesium'); | ||
const oldCesium = global.Cesium; | ||
|
||
requirejs('Cesium'); | ||
module.exports = global.Cesium; | ||
|
||
module.exports = requirejs('Cesium/Cesium'); | ||
if (hadCesiumProperty) { | ||
global.Cesium = oldCesium; | ||
} else { | ||
delete global.Cesium; | ||
} |