【问题标题】:webpack --config webpack.config.vendor.js results in TypeError: dep.getResourceIdentifiier is not a functionwebpack --config webpack.config.vendor.js 导致 TypeError: dep.getResourceIdentifier is not a function
【发布时间】:2018-07-13 19:25:19
【问题描述】:

在 Visual Studio 2017 和 Visual Studio 2017 预览版中,我正在从模板创建一个新的 ASP.Net Core 2.1 Angular 应用程序。不幸的是,每次我尝试运行 webpack --config webpack.config.vendor.js 我都会收到

 TypeError: dep.getResourceIdentifier is not a function
    at addDependency (C:\Users\bdellinger\AppData\Roaming\npm\node_modules\webpack\lib\Compilation.js:387:30)
    at iterationOfArrayCallback (C:\Users\bdellinger\AppData\Roaming\npm\node_modules\webpack\lib\Compilation.js:78:3)
    at addDependenciesBlock (C:\Users\bdellinger\AppData\Roaming\npm\node_modules\webpack\lib\Compilation.js:407:5)
    at Compilation.processModuleDependencies (C:\Users\bdellinger\AppData\Roaming\npm\node_modules\webpack\lib\Compilation.js:418:4) ...

这是我的 package.json(我尝试了从 2 到 4 的许多不同版本的 webpack,但总是得到相同的东西)

{
  "name": "AngularSPABootstrap4",
  "private": true,
  "version": "0.0.0",
  "scripts": {
    "test": "karma start ClientApp/test/karma.conf.js"
  },
  "devDependencies": {
    "@angular/animations": "5.2.1",
    "@angular/common": "5.2.1",
    "@angular/compiler": "5.2.1",
    "@angular/compiler-cli": "5.2.1",
    "@angular/core": "5.2.1",
    "@angular/forms": "5.2.1",
    "@angular/http": "5.2.1",
    "@angular/platform-browser": "5.2.1",
    "@angular/platform-browser-dynamic": "5.2.1",
    "@angular/platform-server": "5.2.1",
    "@angular/router": "5.2.1",
    "@ngtools/webpack": "1.9.5",
    "@types/chai": "4.0.1",
    "@types/jasmine": "2.5.53",
    "@types/webpack-env": "1.13.0",
    "angular2-router-loader": "0.3.5",
    "angular2-template-loader": "0.6.2",
    "aspnet-prerendering": "^3.0.1",
    "aspnet-webpack": "^3.0.0",
    "awesome-typescript-loader": "3.2.1",
    "bootstrap": "4.0.0",
    "chai": "4.0.2",
    "css": "2.2.1",
    "css-loader": "0.28.4",
    "es6-shim": "0.35.3",
    "event-source-polyfill": "0.0.9",
    "expose-loader": "0.7.3",
    "extract-text-webpack-plugin": "2.1.2",
    "file-loader": "0.11.2",
    "html-loader": "0.4.5",
    "isomorphic-fetch": "2.2.1",
    "jasmine-core": "2.6.4",
    "jquery": "3.2.1",
    "json-loader": "0.5.4",
    "karma": "1.7.0",
    "karma-chai": "0.1.0",
    "karma-chrome-launcher": "2.2.0",
    "karma-cli": "1.0.1",
    "karma-jasmine": "1.1.0",
    "karma-webpack": "2.0.3",
    "preboot": "4.5.2",
    "raw-loader": "0.5.1",
    "reflect-metadata": "0.1.10",
    "rxjs": "5.5.6",
    "style-loader": "0.18.2",
    "tabable": "^1.0.0",
    "to-string-loader": "1.1.5",
    "typescript": "2.6.2",
    "url-loader": "0.5.9",
    "webpack": "^3.0.0",
    "webpack-cli": "^3.0.8",
    "webpack-hot-middleware": "2.18.2",
    "webpack-link": "^0.2.0",
    "webpack-merge": "4.1.0",
    "zone.js": "0.8.12"
  },
  "dependencies": {
    "font-awesome": "^4.7.0",
    "popper.js": "^1.12.9"
  }
}

这与这个问题How to add font awesome to ASP.NET Core Angular 2 application in Visual Studio 2017 with SpaTemplates 相关,我正在尝试将字体真棒添加到模板中

【问题讨论】:

    标签: angular webpack visual-studio-2017 asp.net-core-2.0


    【解决方案1】:

    如果您使用新的 ASP.NET Core 2.1 模板,则根本不需要运行 webpack,因为它基于 Angular cli,它在幕后处理这些事情。 要使用 font awesome,只需安装它们提供的 angular 组件。这是来自官方网站的链接。 Font Awesome Angular Component

    如果您不想使用该组件,也可以像这样在 styles.css 中导入:

    @import url('https://use.fontawesome.com/releases/v5.1.0/css/all.css');
    

    然后你可以像在纯 HTML 中这样使用它:

    <i class="fas fa-stroopwafel"></i>
    

    这被描述为here

    【讨论】:

    • 您确定您使用的是最新的模板吗?因为如果您使用 ASP.NET Core 2.1 模板创建 Angular 应用程序,那么您的 Angular 应用程序中根本不应该有 webpack.config 文件。这就像旧的 ASP.NET core 1.1 模板中的那样。
    • 感谢尝试,我现在得到.....拒绝加载图像,因为它违反了以下内容安全策略指令:“default-src 'self'”。请注意,'img-src' 没有显式设置,因此 'default-src' 用作后备。
    • 在没有看到你在做什么的情况下,我无话可说。这看起来像是一个浏览器安全问题。如果有帮助,请检查此post
    猜你喜欢
    • 1970-01-01
    • 2018-11-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-06-05
    • 1970-01-01
    • 2022-10-13
    • 2023-01-05
    相关资源
    最近更新 更多