Skip to content

Commit

Permalink
chore: 优化构建配置
Browse files Browse the repository at this point in the history
  • Loading branch information
cloudcome committed Apr 18, 2023
1 parent b996ec6 commit 7ba5c81
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import path from 'path';
import nodeExternals from 'vite-plugin-node-externals';
import { externalizeDeps } from 'vite-plugin-externalize-deps';
import dts from 'vite-plugin-dts';
import { defineConfig } from 'vitest/config';
import pkg from './package.json';

// https://vitejs.dev/config/
export default defineConfig({
plugins: [
nodeExternals(),
externalizeDeps(),
dts({
insertTypesEntry: true,
}),
Expand All @@ -18,12 +17,13 @@ export default defineConfig({
},
build: {
lib: {
entry: ['src/index.ts', 'src/helpers.ts'],
entry: {
index: 'src/index.ts',
helpers: 'src/helpers.ts',
},
formats: ['es', 'cjs'],
fileName(format, entryName) {
const ext = format === 'es' ? '.mjs' : '.cjs';
const basename = path.basename(entryName, '.ts');
return `${basename}${ext}`;
return entryName + (format === 'es' ? '.mjs' : '.cjs');
},
},
modulePreload: false,
Expand Down

0 comments on commit 7ba5c81

Please sign in to comment.