mall-app-t/peach/utils/uni-get-all-icons.js

35 lines
897 B
JavaScript
Raw Normal View History

2024-05-22 15:42:13 +08:00
'use strict'
Object.defineProperty(exports, '__esModule', { value: true })
const fs = require('fs')
function getAllIconsClass(scssFilePath) {
let result = []
for (const path of scssFilePath) {
console.log(path)
const fileContent = fs.readFileSync(path, 'utf-8')
const regex = /(cicon|_icon|sicon).*:before/g
let matches = fileContent.match(regex)
matches = matches ? matches.map((match) => match.replace(/\:before/, '')) : []
result.push(...matches)
}
return result
}
function uniGetAllIconsPlugin({ scssFilePath }) {
return {
name: 'uni-get-all-icons',
config(config) {
return {
define: {
COLORICONS: getAllIconsClass(scssFilePath),
},
}
},
}
}
exports.default = uniGetAllIconsPlugin