35 lines
897 B
JavaScript
35 lines
897 B
JavaScript
|
'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
|