Skip to content

CSS not working when bundled #7593

@ghost

Description

Bug Report or Feature Request (mark with an x)

- [x] bug report -> please search issues before submitting
- [ ] feature request

Versions.

@angular/cli: 1.3.2
node: 6.11.0
os: win32 x64
@angular/animations: 4.3.6
@angular/common: 4.3.6
@angular/compiler: 4.3.6
@angular/core: 4.3.6
@angular/forms: 4.3.6
@angular/http: 4.3.6
@angular/platform-browser: 4.3.6
@angular/platform-browser-dynamic: 4.3.6
@angular/router: 4.3.6
@angular/cli: 1.3.2
@angular/compiler-cli: 4.3.6
@angular/language-service: 4.3.6

Repro steps.

In command lines:

npm install -g @angular/cli@1.3.2
npm install -g http-server@0.10.0
ng new test-project
cd test-project
npm install popper.js@1.12.5
npm install jquery@3.2.1
npm install boosted@4.0.0-beta.1

Open ./.angular-cli.json and edit the styles and scripts attributes this way:

"styles": [
    "../node_modules/boosted/dist/css/orangeHelvetica.css",
    "../node_modules/boosted/dist/css/orangeIcons.css",
    "../node_modules/boosted/dist/css/boosted.css",
    "styles.css"
],
"scripts": [
    "../node_modules/jquery/dist/jquery.slim.js",
    "../node_modules/popper.js/dist/umd/popper.js",
    "../node_modules/boosted/dist/js/boosted.js"
]

Open ./package.json and add the following to the scripts attribute:

"build:prod": "ng build --target=production --environment=prod",
"build:prod:noextract": "ng build --target=production --environment=prod --extract-css=false"

Open ./src/app/app.component.ts, replace the content with:

<p class="text-primary">.text-primary</p>

In command lines:

npm run build:prod
cd dist
http-server

Open your browser at http://127.0.0.1:8080/, notice that the text isn't colored.
In command lines:

cd ..
npm run build:prod:noextract
cd dist
http-server

Open your browser at http://127.0.0.1:8080/, notice that the text is now colored (cache refresh in your browser might be needed)

The log given by the failure.

N/A

Desired functionality.

The Boosted package that I use in the repro steps is a proprietary fork of Bootstrap, and for some reason it works perfectly fine when the CSS is inside the HTML file (extract-css option set to false) and not at all when it is bundled. I can't manage to reproduce this issue with simpler CSS files. I'm really confused as to what causes this, and putting the CSS into the HTML isn't really acceptable in production.
Thanks in advance for your attention.

Mention any other details that might be useful.

N/A

Metadata

Metadata

Assignees

No one assigned

    Labels

    P1Impacts a large percentage of users; if a workaround exists it is partial or overly painfulneeds: more infoReporter must clarify the issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions