修复样式配置scoped时, 误伤keyframes的bug

pull/1/head 0.7.1
yutent 2023-04-26 15:10:16 +08:00
parent d80fd97601
commit a0f06b0171
3 changed files with 9 additions and 3 deletions

View File

@ -17,7 +17,8 @@ import {
HTML_EXP, HTML_EXP,
CSS_SHEET_EXP, CSS_SHEET_EXP,
HMR_SCRIPT, HMR_SCRIPT,
V_DEEP V_DEEP,
PERCENT_EXP
} from './constants.js' } from './constants.js'
const OPTIONS = { const OPTIONS = {
@ -43,6 +44,10 @@ function scopeCss(css = '', hash) {
selector = selector selector = selector
.map(s => { .map(s => {
// 针对 @keyframe的处理
if (s === 'from' || s === 'to' || PERCENT_EXP.test(s)) {
return s
}
let tmp = s.split(' ') let tmp = s.split(' ')
let last = tmp.pop() let last = tmp.pop()
if (last.includes(':')) { if (last.includes(':')) {

View File

@ -9,7 +9,8 @@ export const STYLE_EXP = /<style([^>]*?)>([\w\W]*?)<\/style>/g
export const HTML_EXP = /<template[^>]*?>([\w\W]*?)\n<\/template>/ export const HTML_EXP = /<template[^>]*?>([\w\W]*?)\n<\/template>/
export const V_DEEP = /:deep\(([^)]*?)\)/ export const V_DEEP = /:deep\(([^)]*?)\)/
export const CSS_SHEET_EXP = /([@\w\.,#\-:>\+\~\|\(\)\[\]"'\=\s]+)\{/g export const CSS_SHEET_EXP = /([%@\w\.,#\-:>\+\~\|\(\)\[\]"'\=\s]+)\{/g
export const PERCENT_EXP = /^\d+%$/
export const COMMON_HEADERS = { export const COMMON_HEADERS = {
'Cache-Control': 'no-store' 'Cache-Control': 'no-store'

View File

@ -1,7 +1,7 @@
{ {
"name": "fite", "name": "fite",
"type": "module", "type": "module",
"version": "0.7.0", "version": "0.7.1",
"bin": { "bin": {
"fite": "index.js" "fite": "index.js"
}, },