使用Netlify部署时出现“未捕获的SyntaxError:意外令牌<”

时间:2020-04-29 12:27:19

标签: caching build netlify

我正在开发一个React应用程序,使用Netlify在提交时自动构建和部署该应用程序。事实是,每当在生产环境中部署新版本时,客户端就会遇到一个空白页面,并显示以下错误:

歌剧: enter image description here Firefox: enter image description here

当导航器第一次加载网站时,不会发生这种情况,只有在新的构建之后才发生。重新加载几次后,问题消失了,网站运行正常。因此,我认为这与缓存有关。

此外,我没有设法在本地重现该错误。这仅在Netlify部署之后发生。

index.html:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <meta name="theme-color" content="#000000">
    <link rel="manifest" href="%PUBLIC_URL%/manifest.json">
    <link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico">
    <script type="text/javascript" src="https://unpkg.com/babel-standalone@6/babel.min.js"></script>
    <title>Sensuba</title>
</head>
<body>
    <noscript>
    You need to enable JavaScript to run this app.
    </noscript>
    <div id="root"></div>

    </body>
</html>

Manifest.json:

{
"short_name": "Sensuba",
"name": "Sensuba",
"icons": [
{
  "src": "favicon.ico",
  "sizes": "64x64 32x32 24x24 16x16",
  "type": "image/x-icon"
}
],
"start_url": "./index.html",
"display": "standalone",
"theme_color": "#000000",
"background_color": "#ffffff"
}

index.js,在/ src文件夹中:

import React from 'react';
import { render } from 'react-dom';
import App from './components/App';
import './style/index.css';
import 'bootstrap/dist/css/bootstrap.min.css';
import registerServiceWorker from './utility/registerServiceWorker';
import Api from './services/Api'

const api = new Api({ url: 'https://bhtwey7kwc.execute-api.eu-west-3.amazonaws.com/alpha' });

const options = { api }

render(
  <App options={options} />,
  document.getElementById('root')
)
registerServiceWorker();

我知道这是一个已知问题,但是我没有在其他线程中找到解决问题的方法。

网站:http://sensuba.netlify.app/

Github:enter link description here

0 个答案:

没有答案