Angular cli从其他包中导入资产

时间:2017-06-12 05:50:29

标签: javascript angular npm webpack angular-cli

我有两个angular-cli项目,一个用于核心组件,第二个用于我的应用程序。

在核心项目中,我有像字体这样的资源。在我的style.scss文件中,我输入的字体如下:

@font-face {
    font-family: 'open_sansregular';
    src: url('/src/assets/fonts/OpenSans-Regular-webfont.woff') format('woff');
    font-weight: normal;
    font-style: normal;
}

当我在主应用程序中安装核心软件包并导入style.scss时,如下所示:

@import '~app-core/src/styles.scss';

我收到错误:

  

找不到   http://localhost:9999/src/assets/fonts/OpenSans-Regular-webfont.woff

我该如何解决这个问题?

1 个答案:

答案 0 :(得分:0)

尝试相对网址

如:

src: url('../assets/fonts/OpenSans-Regular-webfont.woff') format('woff');

以下鳕鱼适合我。

@font-face {
    font-family: 'roboto';
    src: url('../assets/fonts/roboto/Roboto-Regular.ttf') format('truetype');
}