33 lines
781 B
TypeScript
33 lines
781 B
TypeScript
|
|
import { defineConfig } from 'vite';
|
||
|
|
import dts from 'vite-plugin-dts';
|
||
|
|
import { resolve } from 'node:path';
|
||
|
|
import { fileURLToPath } from 'node:url';
|
||
|
|
|
||
|
|
const __dirname = fileURLToPath(new URL('.', import.meta.url));
|
||
|
|
|
||
|
|
export default defineConfig({
|
||
|
|
build: {
|
||
|
|
lib: {
|
||
|
|
entry: resolve(__dirname, 'src/index.ts'),
|
||
|
|
formats: ['es', 'cjs'],
|
||
|
|
fileName: (format) => `index.${format === 'es' ? 'mjs' : 'cjs'}`,
|
||
|
|
},
|
||
|
|
rollupOptions: {
|
||
|
|
// uni / plus / wx 是 uni-app 运行时注入的全局变量,无需 external
|
||
|
|
external: ['vue', 'lodash', /^@r-utils\/.*/],
|
||
|
|
},
|
||
|
|
sourcemap: true,
|
||
|
|
},
|
||
|
|
resolve: {
|
||
|
|
alias: {
|
||
|
|
'@': resolve(__dirname, 'src'),
|
||
|
|
},
|
||
|
|
},
|
||
|
|
plugins: [
|
||
|
|
dts({
|
||
|
|
include: ['src'],
|
||
|
|
outDir: 'dist',
|
||
|
|
}),
|
||
|
|
],
|
||
|
|
});
|