错误:在Firebase Hosting中部署VueJS应用程序

4

我有一个Vue应用程序,我安装了Firebase工具并将应用程序上传到Firebase托管,第一次全部完成并且我执行npm run buildfirebase deploy,但当我进行任何更改后,稍后执行npm run servebuildfirebase deploy时,我会遇到以下错误:

Template execution failed: ReferenceError: features is not defined

  ReferenceError: features is not defined

  - index.html:4 eval
    [.]/[html-webpack-plugin]/lib/loader.js!./public/index.html:4:10

  - index.html:7 module.exports
    [.]/[html-webpack-plugin]/lib/loader.js!./public/index.html:7:3

  - index.js:284 Promise.resolve.then
    [real]/[html-webpack-plugin]/index.js:284:18


  - next_tick.js:188 process._tickCallback
    internal/process/next_tick.js:188:7

有什么想法吗?我不知道为什么这个问题会成功。谢谢。

2个回答

9

当你安装Firebase工具时,它会为你生成一个public文件夹。在该public文件夹中,有一个index.html文件(这个文件是错误的原因)。只需删除index.html文件中的所有内容,然后用你自己的内容进行替换即可。


3
在托管中的 firebase.json 文件中将 "public": "public" 更改为 "public": "dist"。 当您安装 firebase 后,它会更改 public/index.html 文件,原始版本如下:
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width,initial-scale=1.0">
    <link rel="icon" href="<%= BASE_URL %>favicon.ico">
    <title>hello-world-vuetify</title>
    <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:100,300,400,500,700,900">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@mdi/font@latest/css/materialdesignicons.min.css">
  </head>
  <body>
    <noscript>
      <strong>We're sorry but hello-world-vuetify doesn't work properly without JavaScript enabled. Please enable it to continue.</strong>
    </noscript>
    <div id="app"></div>
    <!-- built files will be auto injected -->
  </body>
</html>

替换内容,这对我有效


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接