mirror of
https://gitee.com/dcloud/uni-preset-vue
synced 2025-04-26 23:10:13 +08:00
feat: add types
This commit is contained in:
parent
b8774b1f8a
commit
20b75a99e3
27
generator.js
27
generator.js
@ -31,16 +31,19 @@ async function generate (dir, files, base = '', rootOptions = {}) {
|
||||
})
|
||||
}
|
||||
|
||||
module.exports = (api, options, rootOptions) => {
|
||||
api.extendPackage(pkg => {
|
||||
return {
|
||||
dependencies: {
|
||||
'regenerator-runtime': '^0.12.1'// 锁定版本,避免高版本在小程序中出错
|
||||
},
|
||||
devDependencies: {
|
||||
'postcss-comment': '^2.0.0'
|
||||
}
|
||||
}
|
||||
module.exports = (api, options, rootOptions) => {
|
||||
api.extendPackage(pkg => {
|
||||
return {
|
||||
dependencies: {
|
||||
'regenerator-runtime': '^0.12.1',// 锁定版本,避免高版本在小程序中出错
|
||||
'@dcloudio/uni-helper-json': '*'
|
||||
},
|
||||
devDependencies: {
|
||||
'postcss-comment': '^2.0.0',
|
||||
'miniprogram-api-typings': '*',
|
||||
'mini-types': '*'
|
||||
}
|
||||
}
|
||||
})
|
||||
if (options.template !== 'default-ts') {
|
||||
api.extendPackage(pkg => {
|
||||
@ -86,7 +89,7 @@ module.exports = (api, options, rootOptions) => {
|
||||
const template = options.repo || options.template
|
||||
|
||||
const base = 'src'
|
||||
|
||||
await generate(path.resolve(__dirname, './template/common'), files)
|
||||
if (template === 'default') {
|
||||
await generate(path.resolve(__dirname, './template/default'), files, base, rootOptions)
|
||||
} else if (template === 'default-ts') {
|
||||
@ -122,7 +125,5 @@ module.exports = (api, options, rootOptions) => {
|
||||
|
||||
await generate(tmp, files, base)
|
||||
}
|
||||
|
||||
await generate(path.resolve(__dirname, './template/common'), files)
|
||||
})
|
||||
}
|
||||
|
@ -13,7 +13,9 @@
|
||||
"baseUrl": ".",
|
||||
"types": [
|
||||
"webpack-env",
|
||||
"@dcloudio/types/uni-app"
|
||||
"@dcloudio/types/uni-app",
|
||||
"miniprogram-api-typings",
|
||||
"mini-types"
|
||||
],
|
||||
"paths": {
|
||||
"@/*": [
|
||||
|
10
template/common/tsconfig.json
Normal file
10
template/common/tsconfig.json
Normal file
@ -0,0 +1,10 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"types": [
|
||||
"uni-app",
|
||||
"html5plus",
|
||||
"miniprogram-api-typings",
|
||||
"mini-types"
|
||||
]
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user