Angular: How to parse JSON variables into SCSS

后端 未结 3 979
感动是毒
感动是毒 2021-01-12 04:57

Within an Angular application, I do D3 visuals through either plain D3 or Vega. There\'s also SCSS styling going on.

I\'d like to be able to refer to the same globa

3条回答
  •  情话喂你
    2021-01-12 05:53

    Another option is to use raw-loader, it is available by default in angular-cli. This way you can load raw scss file into ts component:

    // Adding `!!` to a request will disable all loaders specified in the configuration
    import scss from '!!raw-loader!./config.scss';
    
    console.info('scss', scss);
    

    You have to declare module in .d.ts file:

    declare module '!!raw-loader!./*.scss';
    

    Then you can extract any information you want.

    So instead of loading JSON into scss you can load scss into ts.

提交回复
热议问题