forked from weijun-lab/Leaflet.TrackPlayer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vite.config.js
31 lines (30 loc) · 1.08 KB
/
vite.config.js
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
import { resolve } from "path";
import { defineConfig } from "vite";
export default defineConfig({
root: "./examples",
base: "./", // 确保 base 是相对路径,以保持正确的资源加载
build: {
minify: "esbuild",
target: "es2015",// 指定输出的兼容目标//https://cn.vitejs.dev/config/build-options.html#build-target
outDir: "../dist", // 指定构建输出目录为根目录下的 dist 文件夹
lib: {
entry: resolve(__dirname, "./src/TrackPlayer.js"),
name: "TrackPlayer", //全局变量名称
fileName: "leaflet-trackplayer",
},
rollupOptions: {
external: ['leaflet'],//指定外部依赖,不会将其打包到bundle中
output: {
chunkFileNames: "src/[name].js", // 按需加载模块的命名规则
assetFileNames: "leaflet.TrackPlayer[extname]", // 静态资源(包括CSS)的命名规则
globals: {
leaflet: 'L', // 定义leaflet的全局变量名,确保umd.js能正确访问到leaflet
},
},
},
},
server: {
open: true,
host: "0.0.0.0",
},
});