Leaflet/build/rollup-config.js
Rich Harris d188cc5ede add pkg.module (#6021)
* add pkg.module version

* get tests to pass

* export noConflict
2018-02-01 10:42:54 -05:00

59 lines
1.2 KiB
JavaScript

// Config file for running Rollup in "normal" mode (non-watch)
import rollupGitVersion from 'rollup-plugin-git-version'
import json from 'rollup-plugin-json'
import gitRev from 'git-rev-sync'
import pkg from '../package.json'
let {version} = pkg;
let release;
// Skip the git branch+rev in the banner when doing a release build
if (process.env.NODE_ENV === 'release') {
release = true;
} else {
release = false;
const branch = gitRev.branch();
const rev = gitRev.short();
version += '+' + branch + '.' + rev;
}
const banner = `/* @preserve
* Leaflet ${version}, a JS library for interactive maps. http://leafletjs.com
* (c) 2010-2017 Vladimir Agafonkin, (c) 2010-2011 CloudMade
*/
`;
const outro = `var oldL = window.L;
exports.noConflict = function() {
window.L = oldL;
return this;
}
// Always export us to window global (see #2364)
window.L = exports;`;
export default {
input: 'src/Leaflet.js',
output: [
{
file: pkg.main,
format: 'umd',
name: 'L',
banner: banner,
outro: outro,
sourcemap: true
},
{
file: pkg.module,
format: 'es',
banner: banner,
sourcemap: true
}
],
legacy: true, // Needed to create files loadable by IE8
plugins: [
release ? json() : rollupGitVersion()
]
};