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

wip(app): nvue styler

上级 0c8f7396
import { objectifier } from '../src' import { objectifier, parse } from '../src'
import { parseCss } from './utils'
async function objectifierRule(input: string) { async function objectifierRule(input: string) {
const { root, messages } = await parseCss(input) const { root, messages } = await parse(input, { logLevel: 'NOTE' })
return { return {
json: objectifier(root), json: objectifier(root),
messages, messages,
......
import { objectifier } from '../src' import { objectifier, parse } from '../src'
import { parseCss } from './utils'
async function objectifierRoot(input: string) { async function objectifierRoot(input: string) {
const { root, messages } = await parseCss(input) const { root, messages } = await parse(input, { logLevel: 'NOTE' })
return { return {
json: objectifier(root), json: objectifier(root),
messages, messages,
......
...@@ -17,9 +17,7 @@ ...@@ -17,9 +17,7 @@
}, },
"license": "Apache-2.0", "license": "Apache-2.0",
"dependencies": { "dependencies": {
"parse-css-font": "^4.0.0" "parse-css-font": "^4.0.0",
},
"devDependencies": {
"postcss": "^8.4.5" "postcss": "^8.4.5"
} }
} }
export { expand } from './expand' export { expand } from './expand'
export { normalize } from './normalize' export { normalize } from './normalize'
export { objectifier } from './objectifier' export { objectifier } from './objectifier'
export { parse } from './parse'
...@@ -13,8 +13,8 @@ import { normalizeMap } from './map' ...@@ -13,8 +13,8 @@ import { normalizeMap } from './map'
const normalized = Symbol('normalized') const normalized = Symbol('normalized')
interface NormalizeOptions { export interface NormalizeOptions {
descendant?: false descendant?: boolean
logLevel?: 'NOTE' | 'WARNING' | 'ERROR' logLevel?: 'NOTE' | 'WARNING' | 'ERROR'
} }
......
import postcss from 'postcss' import postcss from 'postcss'
import { NormalizeOptions } from './normalize'
import { expand, normalize } from '../src' import { expand, normalize } from '../src'
export function parseCss(input: string, filename: string = 'foo.css') {
return postcss([expand, normalize({ descendant: false, logLevel: 'NOTE' })]) interface ParseOpitons extends NormalizeOptions {
filename?: string
}
export function parse(input: string, options: ParseOpitons = {}) {
return postcss([expand, normalize(options)])
.process(input, { .process(input, {
from: filename, from: options.filename || 'foo.css',
}) })
.catch((err: any) => { .catch((err: any) => {
return { return {
......
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册