我正在尝试使用ng serve
构建可以正常工作的项目,但是当我尝试使用ng build --prod
时出现以下错误:
ERROR in Error: Parse Error: <link href=https://fonts.googleapis.com/icon?family=Material+Icons rel="stylesheet">
<link href="styles.bb42829af637ad7517b8.bundle.css" rel="stylesheet"/></head>
<body>
<app-root></app-root>
<script type="text/javascript" src="inline.12e6a1a2e3a1cffc56a7.bundle.js"></script><script type="text/java script" src="polyfills.46af3f84a403e219371b.bundle.js"></script><script type="text/javascript" src="main.1a 6c58d7ac57bf63f021.bundle.js"></script></body>
</html>
- htmlparser.js:240 new HTMLParser
[todo-app]/[html-minifier]/src/htmlparser.js:240:13
- htmlminifier.js:944 minify
[todo-app]/[html-minifier]/src/htmlminifier.js:944:3
- htmlminifier.js:1300 exports.minify
[todo-app]/[html-minifier]/src/htmlminifier.js:1300:16
- index.js:296
[todo-app]/[html-webpack-plugin]/index.js:296:16
- util.js:16 tryCatcher
[todo-app]/[bluebird]/js/release/util.js:16:23
- promise.js:512 Promise._settlePromiseFromHandler
[todo-app]/[bluebird]/js/release/promise.js:512:31
- promise.js:569 Promise._settlePromise
[todo-app]/[bluebird]/js/release/promise.js:569:18
- promise.js:614 Promise._settlePromise0
[todo-app]/[bluebird]/js/release/promise.js:614:10
- promise.js:693 Promise._settlePromises
[todo-app]/[bluebird]/js/release/promise.js:693:18
- async.js:133 Async._drainQueue
[todo-app]/[bluebird]/js/release/async.js:133:16
- async.js:143 Async._drainQueues
[todo-app]/[bluebird]/js/release/async.js:143:10
- async.js:17 Immediate.Async.drainQueues [as _onImmediate]
[todo-app]/[bluebird]/js/release/async.js:17:14
似乎这个错误是由我index.html
文件上的内容引起的,如下所示:
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>To-Do List</title>
<base href="/">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" type="image/x-icon" href="favicon.ico">
<link href="https://fonts.googleapis.com/css?family=Abhaya+Libre|Cormorant+Garamond:600|Montserrat" rel="stylesheet">
<link href=https://fonts.googleapis.com/icon?family=Material+Icons rel="stylesheet">
</head>
<body>
<app-root></app-root>
</body>
整个应用程序可以在GitHub Repo中找到,欢迎任何解决此问题的方法!
答案 0 :(得分:1)
一个问题是以下行没有围绕href属性值的引用:
<link href=https://fonts.googleapis.com/icon?family=Material+Icons rel="stylesheet">
像这样添加:
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">