提交 c7e263d9 编写于 作者: fxy060608's avatar fxy060608

chore: remove warnings when minifying css

上级 ecb5f8ee
......@@ -42,3 +42,12 @@ export const removeInfoFormatter: Formatter = {
return ''
},
}
const REMOVED_WARN_MSGS = ['warnings when minifying css:']
export const removeWarnFormatter: Formatter = {
test(msg) {
return !!REMOVED_WARN_MSGS.find((m) => msg.includes(m))
},
format() {
return ''
},
}
export * from './fs'
export * from './mp'
export * from './env'
export * from './hbx'
export * from './logs'
......
......@@ -2,7 +2,11 @@ import { once } from '@dcloudio/uni-shared'
import { isInHBuilderX } from '../hbx/env'
import { moduleAliasFormatter } from '../hbx/alias'
import { h5ServeFormatter, removeInfoFormatter } from '../hbx/log'
import {
h5ServeFormatter,
removeInfoFormatter,
removeWarnFormatter,
} from '../hbx/log'
export interface Formatter {
test: (msg: string) => boolean
......@@ -11,6 +15,7 @@ export interface Formatter {
const errFormatters: Formatter[] = []
const infoFormatters: Formatter[] = []
const warnFormatters: Formatter[] = []
const initErrFormattersOnce = once(() => {
if (isInHBuilderX()) {
......@@ -31,6 +36,10 @@ const initInfoFormattersOnce = once(() => {
infoFormatters.push(removeInfoFormatter)
})
const initWarnFormattersOnce = once(() => {
warnFormatters.push(removeWarnFormatter)
})
export function formatErrMsg(msg: string) {
initErrFormattersOnce()
const formatter = errFormatters.find(({ test }) => test(msg))
......@@ -48,3 +57,12 @@ export function formatInfoMsg(msg: string) {
}
return msg
}
export function formatWarnMsg(msg: string) {
initWarnFormattersOnce()
const formatter = warnFormatters.find(({ test }) => test(msg))
if (formatter) {
return formatter.format(msg)
}
return msg
}
export { formatErrMsg, formatInfoMsg } from './format'
export { formatErrMsg, formatInfoMsg, formatWarnMsg } from './format'
export function formatMiniProgramEvent(
eventName: string,
{
isCatch,
isCapture,
}: {
isCatch?: boolean
isCapture?: boolean
}
) {
let eventType = 'bind'
if (isCatch) {
eventType = 'catch'
}
if (isCapture) {
return `capture-${eventType}:${eventName}`
}
// 原生组件不支持 bind:input 等写法,统一使用 bindinput
return `${eventType}${eventName}`
}
'use strict';
var version = "3.0.0-alpha-3021020210930001";
var version = "3.0.0-alpha-3021020211012003";
const STAT_VERSION = version;
const STAT_URL = 'https://tongji.dcloud.io/uni/stat';
......
var version = "3.0.0-alpha-3021020210930001";
var version = "3.0.0-alpha-3021020211012003";
const STAT_VERSION = version;
const STAT_URL = 'https://tongji.dcloud.io/uni/stat';
......
import { Plugin, ResolvedConfig } from 'vite'
import {
formatErrMsg,
checkUpdate,
isWindows,
formatErrMsg,
formatInfoMsg,
formatWarnMsg,
} from '@dcloudio/uni-cli-shared'
import { VitePluginUniResolvedOptions } from '..'
......@@ -42,13 +43,19 @@ function initCheckUpdate() {
}
function initLogger({ logger }: ResolvedConfig) {
const { info, error } = logger
const { info, warn, error } = logger
logger.info = (msg, opts) => {
msg = formatInfoMsg(msg)
if (msg) {
return info(msg, opts)
}
}
logger.warn = (msg, opts) => {
msg = formatWarnMsg(msg)
if (msg) {
return warn(msg, opts)
}
}
logger.error = (msg, opts) => {
msg = formatErrMsg(msg)
if (msg) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册