You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
41 lines
1.1 KiB
41 lines
1.1 KiB
import { dirname, resolve } from 'node:path'
|
|
import { fileURLToPath } from 'node:url'
|
|
import { defineConfig } from 'vite'
|
|
import pkg from "./package.json"
|
|
|
|
const __dirname = dirname(fileURLToPath(import.meta.url))
|
|
|
|
function getExternal(): string[] {
|
|
return [
|
|
...Object.keys(pkg.dependencies || {}),
|
|
"os",
|
|
"module",
|
|
"path",
|
|
]
|
|
}
|
|
console.log(getExternal());
|
|
|
|
export default defineConfig({
|
|
build: {
|
|
lib: {
|
|
entry: resolve(__dirname, 'src/main.js'),
|
|
formats: ['es'],
|
|
fileName: () => `[name].js`,
|
|
},
|
|
outDir: resolve(__dirname, 'dist'),
|
|
rollupOptions: {
|
|
// 确保外部化处理那些
|
|
// 你不想打包进库的依赖
|
|
external: getExternal(),
|
|
watch: {
|
|
include: 'src/**',
|
|
exclude: 'node_modules/**',
|
|
},
|
|
output: {
|
|
preserveModules: true,
|
|
preserveModulesRoot: 'src',
|
|
inlineDynamicImports: false,
|
|
},
|
|
},
|
|
},
|
|
})
|