javascript - Gatsby 构建 html 内容为空
问题描述
我有一个在 Gatsby@2.2.10 完成的网站。当我运行gatsby build
并检查生成的 html 时,对于每个页面,我看到的只是一个空的 div: <div id="___gatsby"></div
。html 包含样式表、javascript 文件和运行应用程序所需的一切(顺便说一下)。
即使我curl
是生产 url,也会出现相同的 div 并且完全为空。我还尝试禁用 javascript,但我得到的只是一个空白页。我的配置不包含任何花哨的内容:
module.exports = {
siteMetadata: {
title : `MyApp`,
description: ``,
author : ``,
},
plugins : [
`gatsby-plugin-react-helmet`,
{
resolve: `gatsby-source-filesystem`,
options: {
name: `images`,
path: `${__dirname}/src/static/images`,
},
},
{
resolve: `gatsby-plugin-less`,
options: {
javascriptEnabled: true,
},
},
`gatsby-transformer-sharp`,
`gatsby-plugin-sass`,
`gatsby-plugin-sharp`,
`gatsby-plugin-typescript`,
`gatsby-plugin-styled-components`,
{
resolve: `gatsby-plugin-google-fonts`,
options: {
fonts: [
`Montserrat\:200,400,600,800`,
],
},
},
{
resolve: `gatsby-plugin-manifest`,
options: {
name : `MyApp.com`,
short_name : `MyApp`,
start_url : `/`,
background_color: `#4DECDB`,
theme_color : `#2F57E4`,
display : `minimal-ui`,
icon : `src/static/images/logo.png`,
},
},
`gatsby-plugin-offline`,
{
resolve: `gatsby-plugin-google-analytics`,
options: {
// replace "UA-XXXXXXXXX-X" with your own Tracking ID
trackingId: 'UA-111111111-16',
},
},
// last
'gatsby-plugin-netlify',
],
}
我的gatbsy-node
文件是空的,gatsby-browser
只加载了一个样式表和一个 redux 存储:
import wrapWithProvider from './wrap-wit-provider'
import './src/components/layout/styles.less'
export const wrapRootElement = wrapWithProvider
任何想法我应该寻找什么?除非 Netlify 由于不存在 html 代码而无法检测到我的表单并处理它们,否则我不会那么担心。
解决方案
我到这里在 gatsby build 上搜索“空白页”,在我的情况下,这个问题是一个愚蠢的问题,希望它对某人有所帮助。
如果public
文件夹已被修改,或文件被移动,gatsby 将失败。只需删除整个文件夹并重建工作正常。
推荐阅读
- asp.net - 如何将控制器从一个类库使用到另一个类库?ASP.NET
- php - 默认 URL 目录
- spring - 通过字段“userTokenService”表示的不满足的依赖关系
- docker - Microsoft Azure Devops 托管代理映像无法正常工作
- c# - 查找 ContentPresenter 的内容并设置样式
- r - 根据特定值导入 CSV 文件
- environment-variables - 从 yml 文件创建环境避免 pip 可安装包?
- scala - SBT 1.2.8 解决关键引用挂起
- html - 比混合混合模式更好的选择?
- python - PySpark - 更改嵌套数组元素的数据类型