2019-11-21 13:44:32 +08:00
|
|
|
import path from 'path';
|
|
|
|
import alias from '@rollup/plugin-alias';
|
|
|
|
import json from '@rollup/plugin-json';
|
|
|
|
import resolve from 'rollup-plugin-node-resolve';
|
|
|
|
import commonjs from 'rollup-plugin-commonjs';
|
|
|
|
import { terser } from "rollup-plugin-terser";
|
|
|
|
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';
|
2019-11-21 13:44:32 +08:00
|
|
|
|
|
|
|
function resolveFile(filePath) {
|
|
|
|
return path.join(__dirname, '..', filePath)
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = [
|
|
|
|
{
|
|
|
|
input: resolveFile('build/bundle.ts'),
|
|
|
|
output: {
|
2019-11-21 18:46:52 +08:00
|
|
|
file: resolveFile('packages/l7/dist/l7.js'),
|
2019-11-21 13:44:32 +08:00
|
|
|
format: 'umd',
|
|
|
|
name: 'L7',
|
|
|
|
globals: {
|
|
|
|
'mapbox-gl': 'mapboxgl',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
external: [
|
|
|
|
'mapbox-gl',
|
|
|
|
],
|
|
|
|
treeshake: true,
|
|
|
|
plugins: [
|
|
|
|
alias(
|
|
|
|
{
|
|
|
|
resolve: ['.tsx', '.ts'],
|
|
|
|
entries: [
|
|
|
|
{
|
|
|
|
find: /^@l7\/(.*)/,
|
|
|
|
replacement: resolveFile('packages/$1/src'),
|
|
|
|
},
|
|
|
|
]
|
|
|
|
},
|
|
|
|
),
|
|
|
|
resolve({
|
|
|
|
browser: true,
|
|
|
|
preferBuiltins: false,
|
|
|
|
extensions: ['.js', '.ts'],
|
|
|
|
}),
|
|
|
|
glsl(
|
|
|
|
['**/*.glsl'],
|
|
|
|
true,
|
|
|
|
),
|
|
|
|
json(),
|
2019-11-21 17:36:04 +08:00
|
|
|
postcss({
|
|
|
|
plugins: [
|
|
|
|
url({ url: 'inline' }),
|
|
|
|
],
|
|
|
|
}),
|
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' ],
|
|
|
|
// @see https://github.com/rollup/rollup-plugin-commonjs/issues/266
|
|
|
|
lodash: [
|
|
|
|
'isNil',
|
|
|
|
'uniq',
|
|
|
|
'clamp',
|
|
|
|
'isObject',
|
|
|
|
'isFunction',
|
|
|
|
'cloneDeep',
|
|
|
|
'isString',
|
|
|
|
'isNumber',
|
|
|
|
],
|
|
|
|
}
|
|
|
|
}),
|
|
|
|
babel({
|
|
|
|
extensions: ['.js', '.ts'],
|
|
|
|
}),
|
|
|
|
terser(),
|
|
|
|
analyze({
|
|
|
|
summaryOnly: true,
|
|
|
|
limit: 20,
|
|
|
|
}),
|
|
|
|
],
|
|
|
|
},
|
|
|
|
];
|