diff --git a/package.json b/package.json index 7474e111e75..0068afef284 100644 --- a/package.json +++ b/package.json @@ -102,6 +102,7 @@ "rollup-plugin-commonjs": "^8.2.6", "rollup-plugin-flow": "^1.1.1", "rollup-plugin-node-resolve": "3.0.0", + "rollup-plugin-sourcemaps": "^0.4.2", "rollup-plugin-uglify": "^3.0.0", "sinon": "^2.1.0", "slugg": "^1.2.1", diff --git a/rollup.config.js b/rollup.config.js index d6eda81071f..97b5c54bde2 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -7,17 +7,19 @@ import json from 'rollup-plugin-json'; import browserifyPlugin from 'rollup-plugin-browserify-transform'; import brfs from 'brfs'; import uglify from 'rollup-plugin-uglify' +import sourcemaps from 'rollup-plugin-sourcemaps'; import minifyStyleSpec from './build/rollup_plugin_minify_style_spec'; const production = process.env.BUILD === 'production'; const outputFile = production ? 'dist/mapbox-gl.js' : 'dist/mapbox-gl-dev.js'; const plugins = [ - flow(), + sourcemaps(), + flow({pretty: true}), // setting {pretty: true} works around https://github.com/leebyron/rollup-plugin-flow/issues/5 minifyStyleSpec(), json(), buble({transforms: {dangerousForOf: true}, objectAssign: "Object.assign"}), - unassert(), + production ? unassert() : false, resolve({ browser: true, preferBuiltins: false @@ -29,12 +31,9 @@ const plugins = [ namedExports: { '@mapbox/gl-matrix': ['vec3', 'vec4', 'mat2', 'mat3', 'mat4'] } - }) -] - -if (production) { - plugins.push(uglify()); -} + }), + production ? uglify() : false +].filter(Boolean) const config = [{ input: ['src/index.js', 'src/source/worker.js'], @@ -54,7 +53,7 @@ const config = [{ format: 'umd', sourcemap: production ? true : 'inline' }, - plugins: production ? [] : [uglify()], + plugins: production ? [sourcemaps(), uglify()] : [sourcemaps()], intro: ` let shared, worker, mapboxgl; function define(_, module) { diff --git a/yarn.lock b/yarn.lock index 51b3b100877..20ab882dc8e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -8632,6 +8632,13 @@ rollup-plugin-node-resolve@3.0.0: is-module "^1.0.0" resolve "^1.1.6" +rollup-plugin-sourcemaps@^0.4.2: + version "0.4.2" + resolved "https://registry.yarnpkg.com/rollup-plugin-sourcemaps/-/rollup-plugin-sourcemaps-0.4.2.tgz#62125aa94087aadf7b83ef4dfaf629b473135e87" + dependencies: + rollup-pluginutils "^2.0.1" + source-map-resolve "^0.5.0" + rollup-plugin-uglify@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/rollup-plugin-uglify/-/rollup-plugin-uglify-3.0.0.tgz#a34eca24617709c6bf1778e9653baafa06099b86"