mirror of
https://github.com/FoggedLens/iD.git
synced 2026-05-14 21:28:11 +02:00
Make separate rollup config files for different builds
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
/* eslint-disable no-console */
|
||||
import commonjs from '@rollup/plugin-commonjs';
|
||||
import includePaths from 'rollup-plugin-includepaths';
|
||||
import json from '@rollup/plugin-json';
|
||||
import nodeResolve from '@rollup/plugin-node-resolve';
|
||||
|
||||
|
||||
// The "dev" build includes all modules in a single bundle - for now
|
||||
// * Skips transpilation (so it includes ES6 code and must run in a modern browser)
|
||||
// * Also generates sourcemaps
|
||||
|
||||
export default {
|
||||
input: './modules/id.js',
|
||||
onwarn: onWarn,
|
||||
output: {
|
||||
file: 'dist/iD.js',
|
||||
format: 'iife',
|
||||
sourcemap: true,
|
||||
strict: false
|
||||
},
|
||||
plugins: [
|
||||
includePaths({
|
||||
paths: ['node_modules/d3/node_modules'], // npm2 or windows
|
||||
include: {
|
||||
'martinez-polygon-clipping': 'node_modules/martinez-polygon-clipping/dist/martinez.umd.js'
|
||||
}
|
||||
}),
|
||||
nodeResolve({
|
||||
mainFields: ['module', 'main'],
|
||||
browser: false,
|
||||
dedupe: ['object-inspect']
|
||||
}),
|
||||
commonjs(),
|
||||
json({ indent: '' })
|
||||
]
|
||||
};
|
||||
|
||||
function onWarn(warning, warn) {
|
||||
// skip certain warnings
|
||||
if (warning.code === 'CIRCULAR_DEPENDENCY') return;
|
||||
if (warning.code === 'EVAL') return;
|
||||
|
||||
// Use default for everything else
|
||||
console.log(warning.code);
|
||||
warn(warning);
|
||||
}
|
||||
@@ -5,6 +5,11 @@ import includePaths from 'rollup-plugin-includepaths';
|
||||
import json from '@rollup/plugin-json';
|
||||
import nodeResolve from '@rollup/plugin-node-resolve';
|
||||
|
||||
|
||||
// The "legacy" build includes all modules in a single bundle:
|
||||
// * Runs `buble` to transpile ES6 -> ES5 (needed for IE11 and PhantomJS)
|
||||
// * No sourcemaps
|
||||
|
||||
export default {
|
||||
input: './modules/id.js',
|
||||
onwarn: onWarn,
|
||||
@@ -0,0 +1,50 @@
|
||||
/* eslint-disable no-console */
|
||||
import commonjs from '@rollup/plugin-commonjs';
|
||||
import includePaths from 'rollup-plugin-includepaths';
|
||||
import json from '@rollup/plugin-json';
|
||||
import nodeResolve from '@rollup/plugin-node-resolve';
|
||||
import visualizer from 'rollup-plugin-visualizer';
|
||||
|
||||
|
||||
// The "stats" build is just like the "dev" build,
|
||||
// but it includes the visualizer plugin to generate a statistics page (slow)
|
||||
|
||||
export default {
|
||||
input: './modules/id.js',
|
||||
onwarn: onWarn,
|
||||
output: {
|
||||
file: 'dist/iD.js',
|
||||
format: 'iife',
|
||||
sourcemap: true,
|
||||
strict: false
|
||||
},
|
||||
plugins: [
|
||||
includePaths({
|
||||
paths: ['node_modules/d3/node_modules'], // npm2 or windows
|
||||
include: {
|
||||
'martinez-polygon-clipping': 'node_modules/martinez-polygon-clipping/dist/martinez.umd.js'
|
||||
}
|
||||
}),
|
||||
nodeResolve({
|
||||
mainFields: ['module', 'main'],
|
||||
browser: false,
|
||||
dedupe: ['object-inspect']
|
||||
}),
|
||||
commonjs(),
|
||||
json({ indent: '' }),
|
||||
visualizer({
|
||||
filename: 'docs/statistics.html',
|
||||
sourcemap: true
|
||||
})
|
||||
]
|
||||
};
|
||||
|
||||
function onWarn(warning, warn) {
|
||||
// skip certain warnings
|
||||
if (warning.code === 'CIRCULAR_DEPENDENCY') return;
|
||||
if (warning.code === 'EVAL') return;
|
||||
|
||||
// Use default for everything else
|
||||
console.log(warning.code);
|
||||
warn(warning);
|
||||
}
|
||||
+4
-1
@@ -12,7 +12,10 @@
|
||||
"scripts": {
|
||||
"all": "npm-run-all -s clean build build:legacy dist",
|
||||
"build": "node --max-old-space-size=4096 build.js",
|
||||
"build:legacy": "rollup --config rollup.config.legacy.js",
|
||||
"build:all": "npm-run-all -s build:development",
|
||||
"build:dev": "rollup --config config/rollup.config.dev.js",
|
||||
"build:legacy": "rollup --config config/rollup.config.legacy.js",
|
||||
"build:stats": "rollup --config config/rollup.config.stats.js",
|
||||
"clean": "shx rm -f dist/*.js dist/*.map dist/*.css dist/img/*.svg",
|
||||
"dist": "npm-run-all -p dist:**",
|
||||
"dist:mapillary": "shx mkdir -p dist/mapillary-js && shx cp -R node_modules/mapillary-js/dist/* dist/mapillary-js/",
|
||||
|
||||
Reference in New Issue
Block a user