Skip to content

Add instructions for compiling SCSS with @ngtools/webpack #6252

@simon-xiong-ca

Description

@simon-xiong-ca

Bug Report or Feature Request (mark with an x)

  • bug report -> please search issues before submitting
  • feature request

Versions.

@angular/cli: 1.0.2
node: 6.10.3
os: darwin x64
@angular/animations: 4.1.1
@angular/common: 4.1.1
@angular/compiler-cli: 4.1.1
@angular/compiler: 4.1.1
@angular/core: 4.1.1
@angular/http: 4.1.1
@angular/platform-browser-dynamic: 4.1.1
@angular/platform-browser: 4.1.1
@angular/platform-server: 4.1.1
@angular/router: 4.1.1
@ngtools/webpack: 1.3.1

Repro steps.

In the README, it says @ngtools/webpack is able to compile SCSS/LESS. I searched the issues, but couldn't find instructions on how to set that up.

Request: Could you please add some instructions for setting up compilation of SCSS/LESS?

Here's what I'm trying to do:

// app.component.ts
@Component({
  ...,
  template: `<h3>Hi</h3>`,
  styleUrls: [
    './app.component.scss'
  ]
})
// app.component.scss
$red: red;

h3 {
  color: $red;
}
// webpack.config.js
...
module: {
  rules: [
    { test: /\.ts$/, loader: '@ngtools/webpack' },
    { test: /\.scss$/, loader: 'raw-loader' },
    { test: /\.css$/, loader: 'raw-loader' },
    { test: /\.html$/, loader: 'raw-loader' }
  ]
}
...

The app builds without any errors, however the styling is not applied.

The log given by the failure.

No error. SCSS does not seem to get compiled.

Desired functionality.

The file app.component.scss should be compiled to CSS, then applied to the component.

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