Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does Angular 2 Ahead-of-Time compiler support SASS stylesheets?

Tags:

I'd like to make another attempt at using Angular 2 Ahead-of-Time compilation.

This will require a significant refactoring on my part because my current setup uses a custom build process that will need to be changed.

Before I start I need to know: if I link to external .scss files in the styleUrls metadata, will the AoT compiler work?

@Component({
    ...
    styleUrls:['./app.component.scss'],
})
export class AppComponent {}

Or should I first convert all my styles to .css and link to CSS stylesheets instead?

The readme doesn't discuss this.

like image 418
BeetleJuice Avatar asked Oct 02 '16 21:10

BeetleJuice


People also ask

What is true with Angular ahead-of-time AOT compiling?

The Angular ahead-of-time (AOT) compiler converts your Angular HTML and TypeScript code into efficient JavaScript code during the build phase before the browser downloads and runs that code. Compiling your application during the build process provides a faster rendering in the browser.

Which stylesheet format for Angular is best?

Angular applications are styled with standard CSS. That means you can apply everything you know about CSS stylesheets, selectors, rules, and media queries directly to Angular applications. Additionally, Angular can bundle component styles with components, enabling a more modular design than regular stylesheets.

What is AOT and JIT in Angular 2?

AOT. JIT downloads the compiler and compiles code exactly before Displaying in the browser. AOT has already complied with the code while building your application, so it doesn't have to compile at runtime. Loading in JIT is slower than the AOT because it needs to compile your application at runtime.

Is AOT default in Angular 12?

Angular compilationThe ng build command with the --prod meta-flag (ng build --prod) compiles with AOT by default.


1 Answers

SASS (.scss files) are not successfully processed by the ahead-of-time compiler (ngc). I've had to convert my stylesheets to .css first

like image 154
BeetleJuice Avatar answered Sep 26 '22 16:09

BeetleJuice