angular - Accessing shared styles from an Angular2 NgModule -


i have angular2 project (generated angular-cli). in project have main module , sub-module. sub-module represents defined concept, fits have (potentially reusable) ngmodule.

the sub-module encapsulates different components, , exposes 1 component outwards. nice, works module reusable.

however, module have 1 global dependency, stops being decoupled, reusable module. scss file accesses common scss file using @import. common scss file outside module.

so, specifically, scss style file inside module refers scss file outside module using relative paths, this:

@import './../../../assets/styles/common-props'; 

i don't want copy scss file module. best way consume common scss file, module becomes easy reuse? there best practice?

not sure if there best practice here. depends on how want import , manage external scss resources.

  1. if want scss resource updated homebrew or npm update importing source directory way go.
  2. if want manually control upgrade path scss resource move file scss hierarchy , import.

generally, prefer approach #2.

i have directory called 'libs' organize external scss / css files , import out of folder structure.

there edge cases use #1, rare.


Comments

Popular posts from this blog

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -