Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add scss file to the Stackblitz

Can you tell me how to add scss file to the stackblitz. I tried that.But it is not working. Please see that and let me know.

I have tried to add home.html

This is the project: stackblitz

like image 904
Sampath Avatar asked Sep 16 '17 09:09

Sampath


People also ask

How do I add components to Stackblitz?

Right click on the app folder and select Angular Generator, then select Component. A small text input box displays at the top of the middle editor pane. Type input-button-unit to create the component. You now have a new component!

How do I change the angular version in Stackblitz?

to the latest angular version by pressing the refresh button in the dependencies tab.


2 Answers

Scss should work in stackblitz:

@Component({
  selector: 'page-home',
  templateUrl: 'home.html',
  styleUrls: [ './home.scss' ] <== add this
})
export class HomePage {

Styles like

 page-home {
 .buttoncls {

won't work for you with default encapsulation(ViewEncapsulation.Emulated) because page-home is not part of home component template and angular adds attribute like [_ngcontent-c0] to styles.

So we can change page-home to ion-list and see how it works:

Stackblitz Example (ViewEncapsulation.Emulated)

But we can disable encapsulation:

encapsulation: ViewEncapsulation.None

Stackblitz Example (ViewEncapsulation.None)

See also this thread

https://github.com/stackblitz/core/issues/1

As EricSimons commented 9 days ago:

Hey all! We just shipped SASS and LESS support, and we also support the angular-cli.json config too :)

like image 127
yurzui Avatar answered Oct 08 '22 14:10

yurzui


Above answer does not work anymore. Update:

@Component({
  selector: 'page-home',
  templateUrl: 'home.html',
  styleUrls: [ 'home.scss' ] <== add this
})

Also - the styles must go in the most outside block and shouldn't go under other block.

like image 2
Noman Avatar answered Oct 08 '22 14:10

Noman