Skip to content

autoprefixer doesn't work on inline component styles #12063

@ghost

Description

Bug Report or Feature Request (mark with an x)

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

Command (mark with an x)

- [ ] new
- [x] build
- [ ] serve
- [ ] test
- [ ] e2e
- [ ] generate
- [ ] add
- [ ] update
- [ ] lint
- [ ] xi18n
- [ ] run
- [ ] config
- [ ] help
- [ ] version
- [ ] doc

Versions

$ ng --version
Angular CLI: 6.1.5
Node: 8.11.4
OS: win32 x64
Angular: 6.1.6
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.7.5
@angular-devkit/build-angular     0.7.5
@angular-devkit/build-optimizer   0.7.5
@angular-devkit/build-webpack     0.7.5
@angular-devkit/core              0.7.5
@angular-devkit/schematics        0.7.5
@angular/cli                      6.1.5
@ngtools/webpack                  6.1.5
@schematics/angular               0.7.5
@schematics/update                0.7.5
rxjs                              6.3.1
typescript                        2.7.2
webpack                           4.9.2

Repro steps

  1. ng new test-styles
  2. Replace app.module.ts with:
import { BrowserModule } from '@angular/platform-browser';
import { NgModule, Component } from '@angular/core';

@Component({
  selector: 'app-root',
  template: '',
  styleUrls: ['./app.component.css']
})
export class AppComponent {}

@Component({
  template: '',
  styles: [`:host { display: grid; }`],
})
export class AppComponent2 {}

@NgModule({
  declarations: [
    AppComponent,
    AppComponent2
  ],
  imports: [BrowserModule],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }
  1. Add CSS to app.component.css:
:host { display: grid; }
  1. ng build

In dist/test-styles/main.js you will see:

/***/ "./src/app/app.component.css":
/*!***********************************!*\
  !*** ./src/app/app.component.css ***!
  \***********************************/
/*! no static exports found */
/***/ (function(module, exports) {

module.exports = ":host { display: -ms-grid; display: grid; }"

/***/ }),

...

var AppComponent2 = /** @class */ (function () {
    function AppComponent2() {
    }
    AppComponent2 = __decorate([
        Object(_angular_core__WEBPACK_IMPORTED_MODULE_1__["Component"])({
            template: '',
            styles: [":host { display: grid; }"],
        })
    ], AppComponent2);
    return AppComponent2;
}());

CSS from app.component.css was processed by autoprefixer, but inline component styles were not.

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