Skip to content

Commit

Permalink
fix: 修复打包配置文件 💩💩
Browse files Browse the repository at this point in the history
  • Loading branch information
Tyh2001 committed Aug 9, 2022
1 parent c7a225e commit 39079a8
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 8 deletions.
14 changes: 10 additions & 4 deletions packages/fighting-design/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand All @@ -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"
Expand All @@ -22,4 +28,4 @@
},
"homepage": "https://fighting.tianyuhao.cn",
"repository": "https://github.com/FightingDesign/fighting-design"
}
}
1 change: 1 addition & 0 deletions start/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
12 changes: 10 additions & 2 deletions vite.config.lib.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,26 +13,34 @@ 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: {
external: ['vue'],
preserveModules: true,
output: {
format: 'cjs',
preserveModules: true,
globals: {
vue: 'Vue'
}
Expand Down
10 changes: 8 additions & 2 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,28 +13,34 @@ 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: {
external: ['vue'],
preserveModules: true,
output: {
format: 'es',
preserveModules: true, // 让打包目录和目录对应
globals: {
vue: 'Vue'
}
Expand Down

0 comments on commit 39079a8

Please sign in to comment.