Skip to content

Component styles not working when defined styleUrlsΒ #6007

@matikrk

Description

@matikrk

Bug Report or Feature Request (mark with an x)

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

Versions.

@angular/cli: 1.0.0
node: 6.10.0
os: win32 x64
@angular/common: 4.0.2
@angular/compiler: 4.0.2
@angular/core: 4.0.2
@angular/forms: 4.0.2
@angular/http: 4.0.2
@angular/platform-browser: 4.0.2
@angular/platform-browser-dynamic: 4.0.2
@angular/router: 4.0.2
@angular/cli: 1.0.0
@angular/compiler-cli: 4.0.2

Repro steps.

When component have styles and styleUrls properties only working styleUrls. After building angularCli (webpack) generate 2 properties styles (1st from styles, 2nd from styleUrls). 2nd property overwrite 1st one.

code:

@Component({
  selector: 'app-smth',
  template: '<div><h1>yo yo</h1></div>',
  styles: ['h1{color:red;}'],
  styleUrls: ['./style.less']
})

after compile:

AccordionComponent = __decorate([
    __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__angular_core__["_3" /* Component */])({
        selector: 'app-smth',
        template: "<div><h1>yo yo</h1></div>",
        styles: ['h1{color:red;}'],
        styles: [__webpack_require__(137)]
    }),
    __metadata("design:paramtypes", [])
], AccordionComponent);

Desired functionality.

When styles and styleUrls are defined should be merged to one array in bundle. Compiled file should look:

AccordionComponent = __decorate([
    __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__angular_core__["_3" /* Component */])({
        selector: 'app-smth',
        template: "<div><h1>yo yo</h1></div>",
        styles: ['h1{color:red;}', __webpack_require__(137)]
    }),
    __metadata("design:paramtypes", [])
], AccordionComponent);

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions