Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: maps 包添加 umd 产物 #2407

Merged
merged 3 commits into from
Apr 16, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/honest-poems-live.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@antv/l7-maps': patch
---

build: mpas 包添加 umd 产物
38 changes: 38 additions & 0 deletions packages/maps/.fatherrc.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,48 @@
import type { IFatherConfig } from 'father';
import { defineConfig } from 'father';
import { BundleAnalyzerPlugin } from 'webpack-bundle-analyzer';

const isProduction = process.env.NODE_ENV === 'production';

const umdConfig: IFatherConfig['umd'] = {
name: 'L7Maps',
output: {
path: './dist',
filename: 'l7-maps.min.js',
},
platform: 'browser',
targets: { ie: 11 },
externals: {
'mapbox-gl': {
root: 'mapboxgl',
commonjs: 'mapbox-gl',
commonjs2: 'mapbox-gl',
amd: 'mapbox-gl',
},
'maplibre-gl': {
root: 'maplibregl',
commonjs: 'maplibre-gl',
commonjs2: 'maplibre-gl',
amd: 'maplibre-gl',
},
},
chainWebpack(memo) {
// 关闭压缩方便调试,默认开启
// memo.optimization.minimize(false);

// 打包体积分析
memo
.plugin('webpack-bundle-analyzer')
.use(BundleAnalyzerPlugin, [{ analyzerMode: 'static', openAnalyzer: false }]);

return memo;
},
};

export default defineConfig({
extends: '../../.fatherrc.base.ts',
// 使用 babel 编译 esm/cjs 产物,启用 transform-import-css-l7 插件完成 CSS 内联打包
esm: { transformer: 'babel' },
cjs: isProduction ? { transformer: 'babel' } : undefined,
umd: isProduction ? umdConfig : undefined,
});
5 changes: 4 additions & 1 deletion packages/maps/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,14 @@
"**/*.css"
],
"main": "lib/index.js",
"unpkg": "dist/l7-maps.min.js",
"module": "es/index.js",
"types": "es/index.d.ts",
"files": [
"dist",
"lib",
"es"
"es",
"!dist/report.html"
],
"scripts": {
"dev": "father dev",
Expand Down
Loading