cmc-web/packages/common/components/icon-select/svgIcons.ts

27 lines
685 B
TypeScript

/*
* @Author: Haijun Zhang
* @Date: 2022-11-03 15:41:09
* @LastEditTime: 2022-11-07 10:39:26
* @LastEditors: Haijun Zhang
* @Description:
* @FilePath: \cmc-web\node_modules\@cmc\common\components\icon-select\svgIcons.ts
*/
// webpack
const req = require.context('@/icons/svg', false, /\.svg$/)
const requireAll = (requireContext: any) => requireContext.keys()
const re = /\.\/(.*)\.svg/;
const svgIcons = requireAll(req).map((i: any) => {
return i.match(re)[1]
})
// vite
// const req = import.meta.globEager('/src/icons/svg/*.svg')
// const re = /\/svg\/(.*)\.svg/
// const svgIcons = Object.keys(req).map(i => {
// return i.match(re)[1]
// })
export default svgIcons