Skip to content

Optimization flag ensures very large deviations of the scss file sizes #19865

@tobiasanton123

Description

@tobiasanton123

Description

Follow up to issue: #19812

Sorry for the late creation of the example repo

I think I found a bug in Angular compiler: It is about the optimization flag in the angular.json file. 

As soon as I set the flag to false, a sample scss file with 70 lines of code has a size of 20kb. Variables are also imported in this file. Only variables and mixins are imported and no other css code. The variable file is about 400 lines in size and estimated 10 of the 400 variables are used in the scss file in question.

If I replace the variables with the values in the file and remove the import, the file falls below my warning size of 8kb.

Angular version 11.1.11 is used.

If I set the optimization flag to true, the the size of the example scss file with variable imports is also smaller than the 8kb warning size.

Sizes of the example scss file:

optimization flag false: 20 kb

optimization flag true: < 2 kb

🔬 Minimal Reproduction

Here is the example repo: https://github.com/tobiasanton123/angular-optimization-flag

The stepts to reproduce are described in the README.md

The name of the example scss file is home.scss and is located in pages/home

🌍 Your Environment

Angular CLI: 11.1.1
Node: 12.18.0
OS: darwin x64

Angular: 11.1.0
... animations, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, router
Ivy Workspace: Yes

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1101.1
@angular-devkit/build-angular   0.1101.1
@angular-devkit/core            11.1.1
@angular-devkit/schematics      11.1.1
@angular/cli                    11.1.1
@schematics/angular             11.1.1
@schematics/update              0.1101.1
rxjs                            6.6.3
typescript                      4.1.3

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions