Skip to content

Commit

Permalink
feat: add build icons js
Browse files Browse the repository at this point in the history
  • Loading branch information
akbarnafisaj committed Apr 27, 2021
1 parent bc4bbef commit 2f3ee05
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 9 deletions.
16 changes: 16 additions & 0 deletions packages/svgs/build/build-icon.js
Expand Up @@ -72,6 +72,7 @@ globby([config.input]).then(icon => {

iconsFiles.push({
name: filename,
path: `icons${outputPath}`,
})
})

Expand All @@ -84,6 +85,21 @@ globby([config.input]).then(icon => {
return a.name < b.name ? -1 : 1
}),
}

const indexIconPath = `${baseConfig.rootDir}/components/icons.js`
try {
fse.unlinkSync(indexIconPath)
} catch (e) {}
fse.outputFileSync(indexIconPath, '')
iconsInfo.icons.forEach(v => {
fse.writeFileSync(
indexIconPath,
fse.readFileSync(indexIconPath).toString('utf-8') +
`export { default as ${v.name} } from './${v.path}'\n`,
'utf-8'
)
})

// generate icons.json
fse.outputFile(
`${baseConfig.rootDir}/components/icons.json`,
Expand Down
16 changes: 16 additions & 0 deletions packages/svgs/build/build-illustration.js
Expand Up @@ -56,6 +56,7 @@ globby([config.input]).then(icon => {
})
illustrationsFiles.push({
name: filename,
path: `illustrations${outputPath}`
})
})

Expand All @@ -69,6 +70,21 @@ globby([config.input]).then(icon => {
}),
}

const indexIconPath = `${baseConfig.rootDir}/components/illustrations.js`
try {
fse.unlinkSync(indexIconPath)
} catch (e) {}

fse.outputFileSync(indexIconPath, '')
illustrationsInfo.illustrations.forEach(v => {
fse.writeFileSync(
indexIconPath,
fse.readFileSync(indexIconPath).toString('utf-8') +
`export { default as ${v.name} } from './${v.path}'\n`,
'utf-8'
)
})

// generate illustrations.json
fse.outputFile(
`${baseConfig.rootDir}/components/illustrations.json`,
Expand Down
5 changes: 3 additions & 2 deletions packages/svgs/components/icons.js
@@ -1,2 +1,3 @@
export { default as IconBell } from './icons/IconBell.vue'
export { default as IconClock } from './icons/IconClock.vue'
export { default as IconBell } from './icons/IconBell'
export { default as IconClock } from './icons/IconClock'
export { default as IconEdit } from './icons/office/IconEdit'
9 changes: 6 additions & 3 deletions packages/svgs/components/icons.json
Expand Up @@ -2,13 +2,16 @@
"iconsCount": 3,
"icons": [
{
"name": "IconBell"
"name": "IconBell",
"path": "icons/IconBell"
},
{
"name": "IconClock"
"name": "IconClock",
"path": "icons/IconClock"
},
{
"name": "IconEdit"
"name": "IconEdit",
"path": "icons/office/IconEdit"
}
]
}
4 changes: 2 additions & 2 deletions packages/svgs/components/illustrations.js
@@ -1,2 +1,2 @@
export { default as IllusInvoice } from './illustrations/IllusInvoice.vue'
export { default as illusOffice } from './illustrations/office/IllusOffice.vue'
export { default as IllusInvoice } from './illustrations/IllusInvoice'
export { default as IllusOffice } from './illustrations/office/IllusOffice'
6 changes: 4 additions & 2 deletions packages/svgs/components/illustrations.json
Expand Up @@ -2,10 +2,12 @@
"illustrationsCount": 2,
"illustrations": [
{
"name": "IllusInvoice"
"name": "IllusInvoice",
"path": "illustrations/IllusInvoice"
},
{
"name": "IllusOffice"
"name": "IllusOffice",
"path": "illustrations/office/IllusOffice"
}
]
}

0 comments on commit 2f3ee05

Please sign in to comment.