Skip to content

Commit

Permalink
minor #2429 [Meta] Replace CleanCSS by LightningCSS (Kocal)
Browse files Browse the repository at this point in the history
This PR was merged into the 2.x branch.

Discussion
----------

[Meta] Replace CleanCSS by LightningCSS

| Q             | A
| ------------- | ---
| Bug fix?      | no
| New feature?  | no <!-- please update src/**/CHANGELOG.md files -->
| Issues        | Fix #... <!-- prefix each issue number with "Fix #", no need to create an issue if none exist, explain below instead -->
| License       | MIT

<!--
Replace this notice by a description of your feature/bugfix.
This will help reviewers and should be a good start for the documentation.

Additionally (see https://symfony.com/releases):
 - Always add tests and ensure they pass.
 - For new features, provide some code snippets to help understand usage.
 - Features and deprecations must be submitted against branch main.
 - Changelog entry should follow https://symfony.com/doc/current/contributing/code/conventions.html#writing-a-changelog-entry
 - Never break backward compatibility (see https://symfony.com/bc).
-->

One more step to modernize our build stack, by replacing https://github.com/clean-css/clean-css by https://lightningcss.dev/.

TBH it does not bring a lot of value since we only have 4 very small CSS files, buuuut that's for a better future :) ([#rolldown](rolldown/rolldown#153 (comment)))

Commits
-------

3f2e4f4 [Meta] Replace CleanCSS by Lightning CSS
  • Loading branch information
Kocal committed Dec 7, 2024
2 parents bcae0c4 + 3f2e4f4 commit 49449f2
Show file tree
Hide file tree
Showing 6 changed files with 132 additions and 17 deletions.
9 changes: 7 additions & 2 deletions bin/build_package.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const path = require('node:path');
const fs = require('node:fs');
const glob = require('glob');
const rollup = require('rollup');
const CleanCSS = require('clean-css');
const LightningCSS = require('lightningcss');
const { getRollupConfiguration } = require('./rollup');

const args = parseArgs({
Expand Down Expand Up @@ -70,7 +70,12 @@ async function main() {

console.log('Minifying CSS...');
const css = await fs.promises.readFile(inputStyleFile, 'utf-8');
const minified = new CleanCSS().minify(css).styles;
const { code: minified } = LightningCSS.transform({
filename: path.basename(inputStyleFile, '.css'),
code: Buffer.from(css),
minify: true,
sourceMap: false, // TODO: Maybe we can add source maps later? :)
});
await fs.promises.writeFile(inputStyleFileDist, minified);
};

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"@rollup/plugin-typescript": "^11.1.6",
"@symfony/stimulus-testing": "^2.0.1",
"@vitest/browser": "^2.1.1",
"clean-css": "^5.3.3",
"lightningcss": "^1.28.2",
"playwright": "^1.47.0",
"rollup": "^4.22.5",
"tslib": "^2.6.3",
Expand Down
2 changes: 1 addition & 1 deletion src/Dropzone/assets/dist/style.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/LiveComponent/assets/dist/live.min.css
Original file line number Diff line number Diff line change
@@ -1 +1 @@
[data-loading=""],[data-loading="delay|show"],[data-loading=show]{display:none}
[data-loading=""],[data-loading=show],[data-loading=delay\|show]{display:none}
2 changes: 1 addition & 1 deletion src/TogglePassword/assets/dist/style.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

132 changes: 121 additions & 11 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4423,15 +4423,6 @@ __metadata:
languageName: node
linkType: hard

"clean-css@npm:^5.3.3":
version: 5.3.3
resolution: "clean-css@npm:5.3.3"
dependencies:
source-map: "npm:~0.6.0"
checksum: 10c0/381de7523e23f3762eb180e327dcc0cedafaf8cb1cd8c26b7cc1fc56e0829a92e734729c4f955394d65ed72fb62f82d8baf78af34b33b8a7d41ebad2accdd6fb
languageName: node
linkType: hard

"clean-stack@npm:^2.0.0":
version: 2.2.0
resolution: "clean-stack@npm:2.2.0"
Expand Down Expand Up @@ -4903,6 +4894,15 @@ __metadata:
languageName: node
linkType: hard

"detect-libc@npm:^1.0.3":
version: 1.0.3
resolution: "detect-libc@npm:1.0.3"
bin:
detect-libc: ./bin/detect-libc.js
checksum: 10c0/4da0deae9f69e13bc37a0902d78bf7169480004b1fed3c19722d56cff578d16f0e11633b7fbf5fb6249181236c72e90024cbd68f0b9558ae06e281f47326d50d
languageName: node
linkType: hard

"detect-newline@npm:^3.0.0":
version: 3.1.0
resolution: "detect-newline@npm:3.1.0"
Expand Down Expand Up @@ -7132,6 +7132,116 @@ __metadata:
languageName: node
linkType: hard

"lightningcss-darwin-arm64@npm:1.28.2":
version: 1.28.2
resolution: "lightningcss-darwin-arm64@npm:1.28.2"
conditions: os=darwin & cpu=arm64
languageName: node
linkType: hard

"lightningcss-darwin-x64@npm:1.28.2":
version: 1.28.2
resolution: "lightningcss-darwin-x64@npm:1.28.2"
conditions: os=darwin & cpu=x64
languageName: node
linkType: hard

"lightningcss-freebsd-x64@npm:1.28.2":
version: 1.28.2
resolution: "lightningcss-freebsd-x64@npm:1.28.2"
conditions: os=freebsd & cpu=x64
languageName: node
linkType: hard

"lightningcss-linux-arm-gnueabihf@npm:1.28.2":
version: 1.28.2
resolution: "lightningcss-linux-arm-gnueabihf@npm:1.28.2"
conditions: os=linux & cpu=arm
languageName: node
linkType: hard

"lightningcss-linux-arm64-gnu@npm:1.28.2":
version: 1.28.2
resolution: "lightningcss-linux-arm64-gnu@npm:1.28.2"
conditions: os=linux & cpu=arm64 & libc=glibc
languageName: node
linkType: hard

"lightningcss-linux-arm64-musl@npm:1.28.2":
version: 1.28.2
resolution: "lightningcss-linux-arm64-musl@npm:1.28.2"
conditions: os=linux & cpu=arm64 & libc=musl
languageName: node
linkType: hard

"lightningcss-linux-x64-gnu@npm:1.28.2":
version: 1.28.2
resolution: "lightningcss-linux-x64-gnu@npm:1.28.2"
conditions: os=linux & cpu=x64 & libc=glibc
languageName: node
linkType: hard

"lightningcss-linux-x64-musl@npm:1.28.2":
version: 1.28.2
resolution: "lightningcss-linux-x64-musl@npm:1.28.2"
conditions: os=linux & cpu=x64 & libc=musl
languageName: node
linkType: hard

"lightningcss-win32-arm64-msvc@npm:1.28.2":
version: 1.28.2
resolution: "lightningcss-win32-arm64-msvc@npm:1.28.2"
conditions: os=win32 & cpu=arm64
languageName: node
linkType: hard

"lightningcss-win32-x64-msvc@npm:1.28.2":
version: 1.28.2
resolution: "lightningcss-win32-x64-msvc@npm:1.28.2"
conditions: os=win32 & cpu=x64
languageName: node
linkType: hard

"lightningcss@npm:^1.28.2":
version: 1.28.2
resolution: "lightningcss@npm:1.28.2"
dependencies:
detect-libc: "npm:^1.0.3"
lightningcss-darwin-arm64: "npm:1.28.2"
lightningcss-darwin-x64: "npm:1.28.2"
lightningcss-freebsd-x64: "npm:1.28.2"
lightningcss-linux-arm-gnueabihf: "npm:1.28.2"
lightningcss-linux-arm64-gnu: "npm:1.28.2"
lightningcss-linux-arm64-musl: "npm:1.28.2"
lightningcss-linux-x64-gnu: "npm:1.28.2"
lightningcss-linux-x64-musl: "npm:1.28.2"
lightningcss-win32-arm64-msvc: "npm:1.28.2"
lightningcss-win32-x64-msvc: "npm:1.28.2"
dependenciesMeta:
lightningcss-darwin-arm64:
optional: true
lightningcss-darwin-x64:
optional: true
lightningcss-freebsd-x64:
optional: true
lightningcss-linux-arm-gnueabihf:
optional: true
lightningcss-linux-arm64-gnu:
optional: true
lightningcss-linux-arm64-musl:
optional: true
lightningcss-linux-x64-gnu:
optional: true
lightningcss-linux-x64-musl:
optional: true
lightningcss-win32-arm64-msvc:
optional: true
lightningcss-win32-x64-msvc:
optional: true
checksum: 10c0/3318770bc7cce1d18acd219ea1e988456b6a5f90a4c09cf12c9ef39c5d4fafff9ba18e798f828131c6d9ece9ae8d544de670becb226ed16e243353c88abc9b41
languageName: node
linkType: hard

"lines-and-columns@npm:^1.1.6":
version: 1.2.4
resolution: "lines-and-columns@npm:1.2.4"
Expand Down Expand Up @@ -8683,7 +8793,7 @@ __metadata:
"@rollup/plugin-typescript": "npm:^11.1.6"
"@symfony/stimulus-testing": "npm:^2.0.1"
"@vitest/browser": "npm:^2.1.1"
clean-css: "npm:^5.3.3"
lightningcss: "npm:^1.28.2"
playwright: "npm:^1.47.0"
rollup: "npm:^4.22.5"
tslib: "npm:^2.6.3"
Expand Down Expand Up @@ -9028,7 +9138,7 @@ __metadata:
languageName: node
linkType: hard

"source-map@npm:^0.6.0, source-map@npm:^0.6.1, source-map@npm:~0.6.0, source-map@npm:~0.6.1":
"source-map@npm:^0.6.0, source-map@npm:^0.6.1, source-map@npm:~0.6.1":
version: 0.6.1
resolution: "source-map@npm:0.6.1"
checksum: 10c0/ab55398007c5e5532957cb0beee2368529618ac0ab372d789806f5718123cc4367d57de3904b4e6a4170eb5a0b0f41373066d02ca0735a0c4d75c7d328d3e011
Expand Down

0 comments on commit 49449f2

Please sign in to comment.