【问题标题】:.net core angular 2 css not found.net core angular 2 css not found
【发布时间】:2017-07-15 02:13:30
【问题描述】:

我正在使用 ASP.NET Core 模板包(Angular 2、Net core、webpack)(plugin website)

现在我需要使用一个不在 mycomponents 文件夹中的 css 文件。

我的文件夹结构:

screenshot

组件

import { Component } from '@angular/core';

@Component({
    selector: 'app',
    template: require('./app.component.html'),
    styles: [require('./mystyle.css')]
 
})
export class AppComponent {
}

然后我运行了命令:

webpack --config webpack.config.vendor.js

我仍然得到错误

调用节点模块失败并出现错误:预渲染因错误而失败:错误:找不到模块“./mystyle.css”

有人可以帮我吗?

谢谢

【问题讨论】:

    标签: css angular webpack asp.net-core


    【解决方案1】:

    您的 css 文件位于不同的文件夹中。

    自定义 CSS 的路径应该是 [require('../../../assets/css/mystyle.css')]

    请注意,默认情况下已经为app.component创建了css文件。

    【讨论】:

    • 我想使用一个全局 css 文件。感谢您的回答!
    猜你喜欢
    • 1970-01-01
    • 2017-06-23
    • 2018-10-26
    • 2018-09-29
    • 1970-01-01
    • 2018-02-16
    • 1970-01-01
    • 1970-01-01
    • 2016-08-29
    相关资源
    最近更新 更多