Compare commits
1 Commits
Author | SHA1 | Date |
---|---|---|
|
46230160ab | 2 months ago |
3 changed files with 45 additions and 2 deletions
Binary file not shown.
@ -0,0 +1,41 @@ |
|||
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, |
|||
}, |
|||
}, |
|||
}, |
|||
}) |
Loading…
Reference in new issue