Skip to content

Commit

Permalink
build: use async clean-css minify
Browse files Browse the repository at this point in the history
  • Loading branch information
clshortfuse committed Jul 20, 2023
1 parent ae65c13 commit 1998faf
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
12 changes: 10 additions & 2 deletions build/esbuild.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,16 @@ const buildOptions = {
treeShaking,
plugins: [
minifyTemplateLiterals({
cssPreprocessor(css) {
return new CleanCSS({}).minify(css).styles;
async cssPreprocessor(css) {
return await new Promise((resolve, reject) => {
new CleanCSS().minify(css, (err, output) => {
if (err) {
reject(err);
} else {
resolve(output.styles);
}
});
});
},
}),
StatisticsPlugin,
Expand Down
10 changes: 9 additions & 1 deletion build/rollup/plugin-minify-template-literals.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,15 @@ export function minifyTemplateLiterals() {
removeComments: true,
});
} else {
data = new CleanCSS({}).minify(raw).styles;
data = await new Promise((resolve, reject) => {
new CleanCSS().minify(raw, (err, output) => {
if (err) {
reject(err);
} else {
resolve(output.styles);
}
});
});
}
return { data, type, raw, start, end };
}),
Expand Down

0 comments on commit 1998faf

Please sign in to comment.