Skip to content

fix: 修复物料合成脚本,支持一个组件多个snippets #1159

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 32 additions & 12 deletions scripts/buildMaterials.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,24 @@ const generateComponents = () => {
materials: {
components: [],
blocks: [],
snippets: []
snippets: [],
packages: [
{
name: 'TinyVue组件库',
package: '@opentiny/vue',
version: '3.20.0',
destructuring: true,
script: 'https://unpkg.com/@opentiny/vue-runtime@~3.20/dist3/tiny-vue-pc.mjs',
css: 'https://unpkg.com/@opentiny/vue-theme@~3.20/index.css'
},
{
name: 'element-plus组件库',
package: 'element-plus',
version: '2.4.2',
script: 'https://unpkg.com/[email protected]/dist/index.full.mjs',
css: 'https://unpkg.com/[email protected]/dist/index.css'
}
]
Comment on lines +97 to +113
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里在 #1200 兼容了。(splitMaterials 的时候分离出来了 packages.json, buildMaterials 的时候读取 packages.json )

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

收到

}
}
}
Expand Down Expand Up @@ -131,20 +148,23 @@ const generateComponents = () => {

if (!valid) return

const { snippets: componentSnippets, category, ...componentInfo } = material
const { snippets: componentSnippets = [], category, ...componentInfo } = material

components.push(componentInfo)

const snippet = snippets.find((item) => item.group === category)

if (snippet) {
componentSnippets && snippet.children.push(componentSnippets[0])
} else if (category && componentInfo) {
snippets.push({
group: category,
children: componentSnippets || []
})
}
componentSnippets.forEach((c) => {
const componentCategory = c.category || category || '其他'
const snippet = snippets.find((item) => item.group === componentCategory)

if (snippet) {
snippet.children.push(c)
} else {
snippets.push({
group: componentCategory,
children: [c]
})
}
})

const { component, npm = {} } = componentInfo

Expand Down