forked from maplibre/maplibre-gl-js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rollup.config.ts
51 lines (48 loc) · 2.01 KB
/
rollup.config.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import fs from 'fs';
import sourcemaps from 'rollup-plugin-sourcemaps';
import {plugins} from './build/rollup_plugins';
import banner from './build/banner';
import {RollupOptions} from 'rollup';
const {BUILD} = process.env;
const production = BUILD === 'production';
const outputFile = production ? 'dist/maplibre-gl.js' : 'dist/maplibre-gl-dev.js';
const config: RollupOptions[] = [{
// Before rollup you should run build-tsc to transpile from typescript to javascript (except when running rollup in watch mode)
// Rollup will use code splitting to bundle GL JS into three "chunks":
// - rollup/build/maplibregl/index.js: the main module, plus all its dependencies not shared by the worker module
// - rollup/build/maplibregl/worker.js: the worker module, plus all dependencies not shared by the main module
// - rollup/build/maplibregl/shared.js: the set of modules that are dependencies of both the main module and the worker module
//
// This is also where we do all of our source transformations using the plugins.
input: ['src/index.ts', 'src/source/worker.ts'],
output: {
dir: 'rollup/build/maplibregl',
format: 'amd',
sourcemap: 'inline',
indent: false,
chunkFileNames: 'shared.js'
},
treeshake: production,
plugins: plugins(production)
}, {
// Next, bundle together the three "chunks" produced in the previous pass
// into a single, final bundle. See rollup/bundle_prelude.js and
// rollup/maplibregl.js for details.
input: 'rollup/maplibregl.js',
output: {
name: 'maplibregl',
file: outputFile,
format: 'umd',
sourcemap: production ? true : 'inline',
indent: false,
intro: fs.readFileSync('./rollup/bundle_prelude.js', 'utf8'),
banner
},
treeshake: false,
plugins: [
// Ingest the sourcemaps produced in the first step of the build.
// This is the only reason we use Rollup for this second pass
sourcemaps()
],
}];
export default config;