fix(build:runtime): 修复打包runtime产物的脚本 (#183)

This commit is contained in:
申君健 2023-04-27 20:35:49 -07:00 committed by GitHub
parent 2cb17701b1
commit 8165b75712
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 24 additions and 16 deletions

View File

@ -20,7 +20,7 @@ export {
`
const buildFullRuntime = () => {
const outputPath = utils.pathFromWorkspaceRoot(outputDir, "app.ts")
const outputPath = utils.pathFromWorkspaceRoot(outputDir, 'app.ts')
const components = moduleUtils.getPcComponents()
const includeTemplate: string[] = []
const componentsTemplate: string[] = []
@ -30,23 +30,23 @@ const buildFullRuntime = () => {
{
name: 'Icon',
importName: '@opentiny/vue-icon',
path: 'packages/vue-icon',
path: 'packages/vue-icon'
},
{
name: 'Locale',
importName: '@opentiny/vue-locale',
path: 'packages/vue-locale',
path: 'packages/vue-locale'
},
{
name: 'Renderless',
importName: '@opentiny/vue-renderless/common/runtime',
path: 'packages/renderless',
path: 'packages/renderless'
},
{
name: 'Common',
importName: '@opentiny/vue-common',
path: 'packages/vue-common',
},
path: 'packages/vue-common'
}
)
components.forEach((item) => {
@ -81,6 +81,7 @@ const buildIconEntry = () => {
let iconEntryContent = fs.readFileSync(inputPath).toString('utf-8')
iconEntryContent = iconEntryContent.replace(/.\/src\//g, './')
iconEntryContent = iconEntryContent.replace("export * from './lowercase'", "export * from '../lowercase'")
fs.writeFileSync(outputPath, iconEntryContent)
}

View File

@ -19,7 +19,7 @@ async function batchBuildAll({ vueVersion, tasks, message, emptyOutDir, npmScope
message,
emptyOutDir,
npmScope,
min,
min
})
function toEntry(libs) {
@ -32,7 +32,7 @@ async function batchBuildAll({ vueVersion, tasks, message, emptyOutDir, npmScope
function getExternal() {
return {
vue: 'Vue',
'@vue/composition-api': 'VueCompositionAPI',
'@vue/composition-api': 'VueCompositionAPI'
}
}
@ -59,7 +59,7 @@ async function batchBuildAll({ vueVersion, tasks, message, emptyOutDir, npmScope
}),
babel({
extensions: ['.js', '.jsx', '.mjs', '.ts', '.tsx'],
presets: ['@babel/preset-env'],
presets: ['@babel/preset-env']
})
)
@ -91,7 +91,7 @@ async function batchBuildAll({ vueVersion, tasks, message, emptyOutDir, npmScope
}
return 'style/[name]-[hash][extname]'
},
}
}
},
lib: {
@ -101,16 +101,22 @@ async function batchBuildAll({ vueVersion, tasks, message, emptyOutDir, npmScope
},
outDir
}
}
)
})
}
}
function getEntryTasks() {
return [{
path: 'vue/app.ts',
libPath: 'app.full',
}]
// 每次都要构建app和图标2个runtime
return [
{
path: 'vue/app.ts',
libPath: 'tiny-vue'
},
{
path: 'vue-icon/index.ts',
libPath: 'tiny-vue-icon'
}
]
}
export async function buildRuntime({

View File

@ -93,6 +93,7 @@ export const getBaseConfig = ({ vueVersion, dtsInclude, dts, buildTarget, themeV
})
: undefined,
inlineChunksPlugin({ deleteInlinedFiles: true }),
// 打包 icon的runtime产物时记得注释掉下面插件
generatePackageJsonPlugin({
beforeWriteFile: (filePath, content) => {
const versionTarget = `${vueVersion}.${buildTarget}`