Add scss file to the Stackblitz

倖福魔咒の 提交于 2019-11-27 06:49:04

问题


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


回答1:


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 :)




回答2:


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.



来源:https://stackoverflow.com/questions/46252546/add-scss-file-to-the-stackblitz

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!