diff --git a/packages/fighting-design/package.json b/packages/fighting-design/package.json index 35770cc85e..110e71b380 100644 --- a/packages/fighting-design/package.json +++ b/packages/fighting-design/package.json @@ -1,6 +1,6 @@ { "name": "fighting-design", - "version": "0.5.1-bate.1", + "version": "0.5.1-bate.2", "description": "Fighting design is a Vue3 lightweight component library written with TypeScript + Template.", "keywords": [ "fighting", @@ -10,8 +10,14 @@ "components", "ui" ], - "main": "./lib/index.lib.js", - "module": "./es/index.es.js", + "main": "./lib/index.js", + "module": "./es/index.js", + "exports": { + ".": { + "require": "./lib/index.js", + "import": "./es/index.js" + } + }, "author": { "name": "tyh2001", "url": "https://tianyuhao.cn" @@ -22,4 +28,4 @@ }, "homepage": "https://fighting.tianyuhao.cn", "repository": "https://github.com/FightingDesign/fighting-design" -} +} \ No newline at end of file diff --git a/start/main.ts b/start/main.ts index a4e5dc504e..79cfe3bc8d 100644 --- a/start/main.ts +++ b/start/main.ts @@ -7,6 +7,7 @@ import '@fighting-design/fighting-theme' // 打包阶段引入 import FightingDesign from '../dist' +// import FightingDesign from '../dist/es/index' // import '../dist/dist/style.css' console.log(FightingDesign) diff --git a/vite.config.lib.ts b/vite.config.lib.ts index 7f477eec30..8015cedaa3 100644 --- a/vite.config.lib.ts +++ b/vite.config.lib.ts @@ -13,19 +13,26 @@ export default (): UserConfigExport => { vueSetupExtend(), vue(), dts({ + insertTypesEntry: false, + cleanVueFileName: true, copyDtsFiles: true }), Components({ dts: resolve(__dirname, '/packages/fighting-components/components.d.ts') }) ], + mode: 'production', build: { + target: 'modules', + minify: false, + chunkSizeWarningLimit: 2, + reportCompressedSize: false, outDir: resolve(__dirname, 'dist/lib'), lib: { entry: resolve(__dirname, 'packages/fighting-components/index.ts'), formats: ['cjs'], - fileName: (target): string => { - return `index.${target}.js` + fileName: (): string => { + return 'index.js' } }, rollupOptions: { @@ -33,6 +40,7 @@ export default (): UserConfigExport => { preserveModules: true, output: { format: 'cjs', + preserveModules: true, globals: { vue: 'Vue' } diff --git a/vite.config.ts b/vite.config.ts index 2b59192b02..1254ab2f37 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -13,21 +13,26 @@ export default (): UserConfigExport => { vueSetupExtend(), vue(), dts({ + insertTypesEntry: false, + cleanVueFileName: true, copyDtsFiles: true // 是否将 .d.ts 源文件复制到 outputDir 中 }), Components({ dts: resolve(__dirname, '/packages/fighting-components/components.d.ts') }) ], + mode: 'production', build: { + target: 'modules', + minify: false, // 压缩 chunkSizeWarningLimit: 2, // 超过 2kb 警告提示 reportCompressedSize: false, outDir: resolve(__dirname, 'dist/es'), lib: { entry: resolve(__dirname, 'packages/fighting-components/index.ts'), formats: ['es'], - fileName: (target): string => { - return `index.${target}.js` + fileName: (): string => { + return 'index.js' } }, rollupOptions: { @@ -35,6 +40,7 @@ export default (): UserConfigExport => { preserveModules: true, output: { format: 'es', + preserveModules: true, // 让打包目录和目录对应 globals: { vue: 'Vue' }