-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
32 lines (31 loc) · 1.25 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
const {resolve} = require('path')
const {compressFont} = require('./util/index.mjs')
const DEFAULT_CONFIG = require('./bin/defaultConfig')
module.exports = (config, ctx) => ({
define() {
const CONFIG = {...DEFAULT_CONFIG, ...config}
for (let i = 0; i < CONFIG.main.length; i++) { // 优先级覆盖逻辑
let item = CONFIG.main[i]
if (!item.content || !item.content.length) {
console.error('noxoneCover:', 'main数组中存在某数组项的content字段未定义或数组为空!')
return
}
let { bgImg, bgImgMobile, bgColor, bgColorMobile } = item
item.bgImg = bgImg || CONFIG.bgImg
item.bgImgMobile = bgImgMobile || bgImg || CONFIG.bgImgMobile || CONFIG.bgImg
item.bgColor = bgColor || CONFIG.bgColor
item.bgColorMobile = bgColorMobile || bgColor || CONFIG.bgColorMobile || CONFIG.bgColor
}
compressFont( // 字体按需压缩
resolve(__dirname, `assets/fonts/${CONFIG.fontFamily}`),
resolve(__dirname, 'assets/fonts'),
'font.min.ttf',
CONFIG.main.map(item => item.content.join('')).join('') + CONFIG.nextTip + CONFIG.skipTip
)
return {
CONFIG
}
},
enhanceAppFiles: resolve(__dirname, './bin/enhanceAppFile.js'),
globalUIComponents: 'Cover'
})