[更新] 打包配置

This commit is contained in:
就眠仪式 2021-09-29 13:31:24 +08:00
parent 7fb98b058b
commit 3324ac6ddf
5 changed files with 21 additions and 76 deletions

View File

@ -1,53 +0,0 @@
const helper = require('components-helper')
const { name, version } = require('./package.json')
helper({
name,
version,
entry: 'docs/docs/en-US/components/*.md',
outDir: 'lib',
reComponentName,
reDocUrl,
reAttribute,
titleRegExp: '#+\\s+(.*)\n+>\\s*([^(#|\\n)]*)',
tableRegExp:
'#+\\s+(.*\\s*Props|.*\\s*Events|.*\\s*Slots|.*\\s*Directives)\\s*\\n+(\\|?.+\\|.+)\\n\\|?\\s*:?-+:?\\s*\\|.+((\\n\\|?.+\\|.+)+)',
})
function reComponentName(title) {
return 'ele-' + title.replace(/\B([A-Z])/g, '-$1').toLowerCase()
}
function reDocUrl(fileName, header) {
// TODO: `zh-CN` -> `en-US`
const docs = 'https://gitee.com/Jmysy/layui-vue'
const _header = header ? header.replace(/[ ]+/g, '-') : undefined
return docs + fileName + (_header ? '#' + header : '')
}
function reAttribute(value, key) {
if (key === 'Name' && /^(-|—)$/.test(value)) {
return 'default'
} else if (key === 'Name' && /v-model:(.+)/.test(value)) {
const _value = value.match(/v-model:(.+)/)
return _value ? _value[1] : undefined
} else if (key === 'Name' && /v-model/.test(value)) {
return 'model-value'
} else if (key === 'Name') {
return value.replace(/\B([A-Z])/g, '-$1').toLowerCase()
} else if (key === 'Type') {
return value
.replace(/\s*\/\s*/g, '|')
.replace(/\s*,\s*/g, '|')
.replace(/\(.*\)/g, '')
.toLowerCase()
} else if (value === '' || /^(-|—)$/.test(value)) {
return undefined
} else if (key === 'Options') {
return /\[.+\]\(.+\)/.test(value) || /^\*$/.test(value)
? undefined
: value.replace(/`/g, '')
} else {
return value
}
}

View File

@ -1,5 +0,0 @@
##### 介绍
<lay-block>
layui谐音类 UI) 是一套开源的 Web UI 解决方案
</lay-block>

View File

@ -12,12 +12,11 @@
"./lib/": "./lib/"
},
"types": "types/index.d.ts",
"style": "lib/style.css",
"style": "lib/layui-vue.css",
"scripts": {
"dev": "vite",
"build": "vite build --emptyOutDir && npm run build:helper && npm run build:types",
"build": "vite build --emptyOutDir && npm run build:types",
"build:types": "rimraf types && tsc -d",
"build:helper": "node .helperrc.js",
"build:docs": "vite build docs",
"test": "jest",
"lint": "eslint . --fix --ext .ts,.vue,.js --ignore-pattern \"/lib/\" --ignore-pattern \"/types/\"",
@ -32,7 +31,7 @@
"layui",
"vue"
],
"author": "<就眠仪式 jmys1992@gmail.com>",
"author": "就眠儀式",
"license": "MIT",
"bugs": {
"url": "https://gitee.com/Jmysy/layui-vue/issues"
@ -60,7 +59,6 @@
"@vue/server-renderer": "^3.1.1",
"@vue/test-utils": "^2.0.0-rc.6",
"babel-jest": "^26.6.3",
"components-helper": "^1.0.3",
"escape-html": "^1.0.3",
"eslint": "^7.25.0",
"eslint-plugin-prettier": "^3.4.0",
@ -81,11 +79,6 @@
"vite-plugin-md": "^0.6.3",
"vue-jest": "^5.0.0-alpha.8"
},
"vetur": {
"tags": "lib/tags.json",
"attributes": "lib/attributes.json"
},
"web-types": "lib/web-types.json",
"files": [
"lib",
"types"

View File

@ -10,11 +10,21 @@
"emitDeclarationOnly": true,
"esModuleInterop": true,
"declarationDir": "types",
"lib": ["ESNext", "DOM"],
"lib": [
"ESNext",
"DOM"
],
"paths": {
"/@src/*": ["./src/*"]
"/@src/*": [
"./src/*"
]
}
},
"include": ["src/**/*", "shims-vue.d.ts"],
"exclude": ["node_modules"]
}
"include": [
"src/**/*",
"shims-vue.d.ts"
],
"exclude": [
"node_modules"
]
}

View File

@ -3,6 +3,7 @@ import { defineConfig } from 'vite'
import babel from 'rollup-plugin-babel'
import { name } from './package.json'
import plugins from './docs/src/plugin/common-plugins'
import { getSystemErrorMap } from 'util'
const camelize = (name: string) =>
name.replace(/(^|-)(\w)/g, (a, b, c) => c.toUpperCase())
@ -20,7 +21,7 @@ export default defineConfig({
lib: {
entry: path.resolve(__dirname, 'src/index.ts'),
name: camelize(name),
},
},
rollupOptions: {
output: {
exports: 'named',
@ -28,9 +29,8 @@ export default defineConfig({
const name = id.replace(/^@/, '').split('/')[0]
return camelize(name)
},
assetFileNames: `layui-vue.css`
},
external: (id: string) =>
/^(vue|@vue|element-plus|resize-observer-polyfill)/.test(id),
plugins: [
babel({
exclude: 'node_modules/**',