From b3cd49bf2219aacffc1ac34acbae7c76ef243765 Mon Sep 17 00:00:00 2001 From: Sean Perkins <13732623+sean-perkins@users.noreply.github.com> Date: Fri, 5 Apr 2024 10:01:20 -0400 Subject: [PATCH] perf(styles): compress distributed global stylesheets (#29275) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Issue number: N/A --------- ## What is the current behavior? Ionic Framework developers make extensive use of multi-line comments in the Sass files. However these comments are not stripped from the generated output. This leads to a significant increase to the file size of CSS and can have an impact on runtime performance. For example: https://cdn.jsdelivr.net/npm/@ionic/core/css/core.css has 183 lines of comment blocks before a single line of CSS. ## What is the new behavior? - Compresses the generated output from Sass → CSS to strip out multi-line comment blocks. - Developers can use [loud comments](https://sass-lang.com/documentation/syntax/comments/) if they want to include comments in the generated output. - In the case of just the core.css file, the file size goes from 20kb to 10kb. - The entire CSS global styles goes from 758 KB to 606kb. ## Does this introduce a breaking change? - [ ] Yes - [x] No ## Other information Dev-build: `7.8.4-dev.11712251308.1da8aede` --- core/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/package.json b/core/package.json index b1b4decf46..04d9c6ce55 100644 --- a/core/package.json +++ b/core/package.json @@ -77,7 +77,7 @@ "build.docs.json": "stencil build --docs-json dist/docs.json", "clean": "node scripts/clean.js", "css.minify": "cleancss -O2 -o ./css/ionic.bundle.css ./css/ionic.bundle.css", - "css.sass": "sass --embed-sources src/css:./css", + "css.sass": "sass --embed-sources --style compressed src/css:./css", "eslint": "eslint src", "lint": "npm run lint.ts && npm run lint.sass && npm run prettier -- --write --cache", "lint.fix": "npm run lint.ts.fix && npm run lint.sass.fix && npm run prettier -- --write --cache",