Skip to content

Postcss plugin through custom-webpack not applied to scss partial files #638

@abierbaum

Description

@abierbaum

Describe the Bug

Adding a postcss plugin using custom-webpack does not apply the plugin to scss partial files imported into the styles.

Minimal Reproduction

A minimal reproduction and instructions is provided here: https://github.com/abierbaum/postcss-custom-webpack-global-issue

Expected Behavior

This repository demonstrates a bug where postcssPresetEnv is added using the @angular-builders/custom-webpack custom builders. The issue is that the postcss plugin extension settings added are not being applied when the build processes scss partial files imported into the styles of the application.

Reproduction steps:

ng run build

Open the dist/postcss-custom-webpack-global-issue/styles.css file. Note that the block of style that came from src/styles.scss directly has it's logical css properties transformed correctly. The ones that are imported by src/styles.scss from shared/styles/_shared.style.scss are not transformed and stay in their original form.

The content end ups looking like:

/* You can add global styles to this file, and also import other style files */
div.container {
  border: 5px solid black;
  -webkit-margin-start: 20px;
          margin-inline-start: 20px;
  -webkit-margin-end: 50px;
          margin-inline-end: 50px;
}
div.container {
  border-left-color: orange;
  border-right-color: orange;
}

/*# sourceMappingURL=styles.css.map*/

For some reason the styles from shared/styles/_shared.style.scss are not being transformed with the added plugin settings.

The expected output would be:

/* You can add global styles to this file, and also import other style files */
div.container {
  border: 5px solid black;
  margin-left: 20px;
  margin-right: 50px;
}
div.container {
  border-left-color: orange;
  border-right-color: orange;
}

/*# sourceMappingURL=styles.css.map*/

Environment


Angular CLI: 8.3.20
Node: 12.13.0
OS: linux x64
Angular: 8.2.14
... animations, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.803.20
@angular-devkit/build-angular     0.803.20
@angular-devkit/build-optimizer   0.803.20
@angular-devkit/build-webpack     0.803.20
@angular-devkit/core              8.3.20
@angular-devkit/schematics        8.3.20
@angular/cli                      8.3.20
@ngtools/webpack                  8.3.20
@schematics/angular               8.3.20
@schematics/update                0.803.20
rxjs                              6.4.0
typescript                        3.5.3
webpack                           4.39.2

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions