Skip to content

Angular 12 production build breaking styles #4

Description

@oobayly

When building using ng build --prod, or the new ng build --configuration production, a style tag is addded to the head element that forces the body min-width to be 992px!important, and completely breaks the responsive layout.

In an attempt to identify the culprit, I removed styles from angular.json until the min-width wasn't added, and found that node_modules/angular-bootstrap-md/assets/scss/bootstrap/bootstrap.scss was the cause.

Expected behavior

The CSS should render the same as when built without the --prod flag.

Actual behavior

The following CSS is injected into the head, breaking the page. Note the body{min-width:992px!important;} at the end.

@charset "UTF-8";:root{--blue:#007bff;--indigo:#6610f2;--purple:#6f42c1;--pink:#e83e8c;--red:#dc3545;--orange:#fd7e14;--yellow:#ffc107;--green:#28a745;--teal:#20c997;--cyan:#17a2b8;--white:#fff;--gray:#6c757d;--gray-dark:#343a40;--primary:#007bff;--secondary:#6c757d;--success:#28a745;--info:#17a2b8;--warning:#ffc107;--danger:#dc3545;--light:#f8f9fa;--dark:#343a40;--breakpoint-xs:0;--breakpoint-sm:576px;--breakpoint-md:768px;--breakpoint-lg:992px;--breakpoint-xl:1200px;--font-family-sans-serif:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,"Noto Sans",sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji";--font-family-monospace:SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace;}*,:after,:before{box-sizing:border-box;}html{font-family:sans-serif;line-height:1.15;-webkit-text-size-adjust:100%;-webkit-tap-highlight-color:rgba(0,0,0,0);}body{font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;font-size:1rem;font-weight:400;line-height:1.5;color:#212529;text-align:left;background-color:#fff;}@page {size:a3;}body{min-width:992px!important;}

Your working environment and MDB version information

  • angular-bootstrap-md - 11.1.0
  • angular - 12.0.4

Resources (screenshots, code snippets etc.)

image

package.json

  "dependencies": {
    "@angular/animations": "~12.0.4",
    "@angular/cdk": "^11.2.13",
    "@angular/common": "~12.0.4",
    "@angular/compiler": "~12.0.4",
    "@angular/core": "~12.0.4",
    "@angular/fire": "^6.1.5",
    "@angular/forms": "~12.0.4",
    "@angular/localize": "^12.0.4",
    "@angular/platform-browser": "~12.0.4",
    "@angular/platform-browser-dynamic": "~12.0.4",
    "@angular/router": "~12.0.4",
    "@angular/service-worker": "~12.0.4",
    "@fortawesome/fontawesome-free": "^5.15.3",
    "@types/uuid": "^8.3.0",
    "@zxing/browser": "0.0.9",
    "@zxing/library": "^0.18.6",
    "@zxing/ngx-scanner": "^3.1.3",
    "angular-bootstrap-md": "^11.1.0",
    "angularx-qrcode": "^11.0.0",
    "animate.css": "^4.1.1",
    "eslint": "^7.28.0",
    "firebase": "^8.3.3",
    "hammerjs": "^2.0.8",
    "rxjs": "^7.1.0",
    "tslib": "^2.3.0",
    "uuid": "^8.3.2",
    "zone.js": "~0.11.4"
  },

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions