2019-11-21 13:44:32 +08:00
|
|
|
import path from 'path';
|
|
|
|
import alias from '@rollup/plugin-alias';
|
|
|
|
import json from '@rollup/plugin-json';
|
2019-12-30 20:06:12 +08:00
|
|
|
import resolve from '@rollup/plugin-node-resolve';
|
2019-12-30 19:22:42 +08:00
|
|
|
import commonjs from '@rollup/plugin-commonjs';
|
2019-11-22 18:21:59 +08:00
|
|
|
import { terser } from 'rollup-plugin-terser';
|
2019-11-21 13:44:32 +08:00
|
|
|
import analyze from 'rollup-plugin-analyzer';
|
|
|
|
import babel from 'rollup-plugin-babel';
|
|
|
|
import glsl from './rollup-plugin-glsl';
|
2019-11-21 17:36:04 +08:00
|
|
|
import postcss from 'rollup-plugin-postcss';
|
|
|
|
import url from 'postcss-url';
|
2020-02-13 16:36:22 +08:00
|
|
|
const { BUILD, MINIFY } = process.env;
|
|
|
|
const minified = MINIFY === 'true';
|
|
|
|
const production = BUILD === 'production';
|
|
|
|
const outputFile = !production
|
|
|
|
? 'packages/l7/dist/l7-dev.js'
|
|
|
|
: minified
|
|
|
|
? 'packages/l7/dist/l7.js'
|
|
|
|
: 'packages/l7/dist/l7-dev.js';
|
2019-11-21 13:44:32 +08:00
|
|
|
function resolveFile(filePath) {
|
2019-11-22 18:21:59 +08:00
|
|
|
return path.join(__dirname, '..', filePath);
|
2019-11-21 13:44:32 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = [
|
|
|
|
{
|
|
|
|
input: resolveFile('build/bundle.ts'),
|
|
|
|
output: {
|
2020-02-13 16:36:22 +08:00
|
|
|
file: resolveFile(outputFile),
|
2019-11-21 13:44:32 +08:00
|
|
|
format: 'umd',
|
|
|
|
name: 'L7',
|
|
|
|
globals: {
|
2019-11-22 18:21:59 +08:00
|
|
|
'mapbox-gl': 'mapboxgl'
|
|
|
|
}
|
2019-11-21 13:44:32 +08:00
|
|
|
},
|
|
|
|
external: [
|
2019-11-22 18:21:59 +08:00
|
|
|
'mapbox-gl'
|
2019-11-21 13:44:32 +08:00
|
|
|
],
|
2020-02-13 16:36:22 +08:00
|
|
|
treeshake: minified,
|
2019-11-21 13:44:32 +08:00
|
|
|
plugins: [
|
|
|
|
alias(
|
|
|
|
{
|
2019-11-22 18:21:59 +08:00
|
|
|
resolve: [ '.tsx', '.ts' ],
|
2019-11-21 13:44:32 +08:00
|
|
|
entries: [
|
|
|
|
{
|
2019-11-25 15:27:56 +08:00
|
|
|
find: /^@antv\/l7-(.*)/,
|
2021-07-03 23:00:24 +08:00
|
|
|
replacement: resolveFile('packages/$1/src')
|
2019-11-25 15:27:56 +08:00
|
|
|
},
|
|
|
|
{
|
|
|
|
find: /^@antv\/l7$/,
|
2021-07-03 23:00:24 +08:00
|
|
|
replacement: resolveFile('packages/l7/src')
|
2019-12-30 20:06:12 +08:00
|
|
|
}
|
2019-11-21 13:44:32 +08:00
|
|
|
]
|
2019-11-22 18:21:59 +08:00
|
|
|
}
|
2019-11-21 13:44:32 +08:00
|
|
|
),
|
|
|
|
resolve({
|
|
|
|
browser: true,
|
|
|
|
preferBuiltins: false,
|
2019-11-22 18:21:59 +08:00
|
|
|
extensions: [ '.js', '.ts' ]
|
2019-11-21 13:44:32 +08:00
|
|
|
}),
|
|
|
|
glsl(
|
2019-11-22 18:21:59 +08:00
|
|
|
[ '**/*.glsl' ],
|
|
|
|
true
|
2019-11-21 13:44:32 +08:00
|
|
|
),
|
|
|
|
json(),
|
2019-11-21 17:36:04 +08:00
|
|
|
postcss({
|
2020-04-22 17:09:24 +08:00
|
|
|
extract: false,
|
2019-11-21 17:36:04 +08:00
|
|
|
plugins: [
|
2019-11-22 18:21:59 +08:00
|
|
|
url({ url: 'inline' })
|
|
|
|
]
|
2019-11-21 17:36:04 +08:00
|
|
|
}),
|
2019-11-21 13:44:32 +08:00
|
|
|
// @see https://github.com/rollup/rollup-plugin-node-resolve#using-with-rollup-plugin-commonjs
|
|
|
|
commonjs({
|
|
|
|
namedExports: {
|
|
|
|
eventemitter3: [ 'EventEmitter' ],
|
2021-07-03 23:00:24 +08:00
|
|
|
inversify: [ 'inject', 'injectable', 'postConstruct', 'Container', 'decorate', 'interfaces' ],
|
2019-11-21 13:44:32 +08:00
|
|
|
// @see https://github.com/rollup/rollup-plugin-commonjs/issues/266
|
|
|
|
lodash: [
|
|
|
|
'isNil',
|
|
|
|
'uniq',
|
2019-11-22 18:21:59 +08:00
|
|
|
'clamp',
|
2019-11-21 13:44:32 +08:00
|
|
|
'isObject',
|
|
|
|
'isFunction',
|
|
|
|
'cloneDeep',
|
|
|
|
'isString',
|
2019-12-26 00:16:33 +08:00
|
|
|
'isNumber',
|
|
|
|
'merge'
|
2019-11-22 18:21:59 +08:00
|
|
|
]
|
2021-02-28 14:53:44 +08:00
|
|
|
},
|
|
|
|
dynamicRequireTargets: [
|
2021-07-03 23:00:24 +08:00
|
|
|
'node_modules/inversify/lib/syntax/binding_{on,when}_syntax.js'
|
|
|
|
]
|
2019-11-21 13:44:32 +08:00
|
|
|
}),
|
|
|
|
babel({
|
2019-11-22 18:21:59 +08:00
|
|
|
extensions: [ '.js', '.ts' ]
|
2019-11-21 13:44:32 +08:00
|
|
|
}),
|
2020-02-13 16:36:22 +08:00
|
|
|
// terser(),
|
|
|
|
minified ? terser() : false,
|
2019-11-21 13:44:32 +08:00
|
|
|
analyze({
|
|
|
|
summaryOnly: true,
|
2019-11-22 18:21:59 +08:00
|
|
|
limit: 20
|
|
|
|
})
|
|
|
|
]
|
|
|
|
}
|
2019-11-21 13:44:32 +08:00
|
|
|
];
|