-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Optimize generated CSS output #14873
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
1a1a9ba
9ecfcb0
d262870
f93e6bc
53b6aff
b0972d8
774290e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -277,24 +277,30 @@ function optimizeCss( | |
input: string, | ||
{ file = 'input.css', minify = false }: { file?: string; minify?: boolean } = {}, | ||
) { | ||
return transform({ | ||
filename: file, | ||
code: Buffer.from(input), | ||
minify, | ||
sourceMap: false, | ||
drafts: { | ||
customMedia: true, | ||
}, | ||
nonStandard: { | ||
deepSelectorCombinator: true, | ||
}, | ||
include: Features.Nesting, | ||
exclude: Features.LogicalProperties, | ||
targets: { | ||
safari: (16 << 16) | (4 << 8), | ||
}, | ||
errorRecovery: true, | ||
}).code.toString() | ||
function optimize(code: Buffer | Uint8Array) { | ||
return transform({ | ||
filename: file, | ||
code, | ||
minify, | ||
sourceMap: false, | ||
drafts: { | ||
customMedia: true, | ||
}, | ||
nonStandard: { | ||
deepSelectorCombinator: true, | ||
}, | ||
include: Features.Nesting, | ||
exclude: Features.LogicalProperties, | ||
targets: { | ||
safari: (16 << 16) | (4 << 8), | ||
}, | ||
errorRecovery: true, | ||
}).code | ||
} | ||
|
||
// Running Lightning CSS twice to ensure that adjacent rules are merged after | ||
// nesting is applied. This creates a more optimized output. | ||
return optimize(optimize(Buffer.from(input))).toString() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wonder if we can get away with running There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah that's tricky. Our config sets Safari to a version that doesn't understand nesting yet. One suggestion that Devon had was to put |
||
} | ||
|
||
function idToPath(id: string) { | ||
|
Uh oh!
There was an error while loading. Please reload this page.