【问题标题】:Symfony Encore, does not build index.html fileSymfony Encore, does not build index.html file
【发布时间】:2022-12-02 09:04:13
【问题描述】:

I've been using an open source website to host a domain.
The original github project is using symfony to build the project.

"scripts": {
    "dev-server": "encore dev-server",
    "dev": "encore dev",
    "watch": "encore dev --watch",
    "build": "encore production --progress"
}

I noticed that when deploying to IPFS, the index.html was using absolute pathing:

<!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">
  
  <title></title>
  <link rel="icon" type="image/png" href="/build/images/fav.png" />

  <link rel="stylesheet" href="/build/main.css">
  <script src="/build/main.js"></script>
</head>
<body>
  <main>
    <img id="logo" src="/build/images/logo.png" alt="Logo" />

    <div id="minting-dapp"></div>
  </main>

  <div id="notifications"></div>
</body>
</html>

So I deleted the index.html file and decided to use rebuild the project, but I noticed that encore, does not build the index.html file ever.

I would like my index.html file to update using with the build.

How can I configure it to use the homepage variable to use relative pathing similar to how npm build works see this answer for reference

【问题讨论】:

    标签: node.js typescript symfony webpack-encore


    【解决方案1】:

    Encore does not build any html files, it generates files for js and css such as vendor files, runtime, ...

    -> Webpack Encore

    If the html file is a index.html.twig

    You can directly specify it in the code :

    <body>
      <main>
        <img id="logo" src="{{ asset('/images/logo.png')}}" alt="Logo" />
    
        <div id="minting-dapp"></div>
      </main>
    
      <div id="notifications"></div>
    </body>
    

    And then it will not use the absolute path -> Check Asset Component

    【讨论】:

      猜你喜欢
      • 2022-12-27
      • 2021-10-01
      • 1970-01-01
      • 2019-09-15
      • 2014-05-18
      • 2013-08-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多