简体   繁体   English

gatsby-cli建立后没有index.html文件吗?

[英]No index.html file after gatsby-cli build?

I'm experimenting with GatsbyJS. 我正在尝试GatsbyJS。 I created a new site derived from their default site generator and made some changes. 我创建了一个从其默认网站生成器派生的新网站,并进行了一些更改。 When using the gatsby develop command everything works as expected. 当使用gatsby develop命令时,一切都会按预期进行。 I went to use gatsby build and it does produce a /public folder, however there's no "index.html" or even "bundle.js" 我使用了gatsby build ,它确实生成了/ public文件夹,但是没有“ index.html”甚至“ bundle.js”

Is the default site "special" in that it won't produce a site the typical way? 默认站点是否为“特殊”站点,因为它不会以典型方式生成站点? Is there another setting needed in the gatsby-config version to produce index.html? gatsby-config版本中是否需要其他设置来生成index.html?

A ls of the /public directory returns: / public目录的ls返回:

1-5cf9b126c8aa029e3c76.js
1-5cf9b126c8aa029e3c76.js.map
1-f2577b7d9227c6ab20bd.js
1-f2577b7d9227c6ab20bd.js.map
404
app-dc0da5ea76a79bd92e99.js
app-dc0da5ea76a79bd92e99.js.map
app-e2d084d7f150c4a0d4f4.js
app-e2d084d7f150c4a0d4f4.js.map
chunk-map.json
component---node-modules-gatsby-plugin-offline-app-shell-js-896a3f852b233b9ca05e.js
component---node-modules-gatsby-plugin-offline-app-shell-js-896a3f852b233b9ca05e.js.map
component---src-pages-404-js-8e1643e05587f89c70d6.js
component---src-pages-404-js-8e1643e05587f89c70d6.js.map
component---src-pages-404-js-c2122e5847e5d16ffe11.js
component---src-pages-404-js-c2122e5847e5d16ffe11.js.map
component---src-pages-index-js-be99ef46e818d68362b3.js
component---src-pages-index-js-be99ef46e818d68362b3.js.map
component---src-pages-index-js-edad0a6dd0d36ec7cdbd.js
component---src-pages-index-js-edad0a6dd0d36ec7cdbd.js.map
component---src-pages-page-2-js-0479e3779ff85cb5431c.js
component---src-pages-page-2-js-0479e3779ff85cb5431c.js.map
component---src-pages-page-2-js-a49a481686ec152c45b7.js
component---src-pages-page-2-js-a49a481686ec152c45b7.js.map
icons
manifest.webmanifest
offline-plugin-app-shell-fallback
pages-manifest-5c619b10fb87f94c2d85.js
pages-manifest-5c619b10fb87f94c2d85.js.map
pages-manifest-e84c50768dd42edc85fe.js
pages-manifest-e84c50768dd42edc85fe.js.map
render-page.js
render-page.js.map
static
styles-0375cdcc38b87565858c.js
styles-0375cdcc38b87565858c.js.map
styles-b76dfad3fcff2976e17c.js
styles-b76dfad3fcff2976e17c.js.map
styles.fc4fa5e094d218207796.css
webpack-runtime-50855368c384639cab1f.js
webpack-runtime-50855368c384639cab1f.js.map
webpack-runtime-66b8792cf68b5ba07ac4.js
webpack-runtime-66b8792cf68b5ba07ac4.js.map
webpack.stats.json

For reference: 以供参考:

$ gatsby -v
2.5.5

And the package.json: 还有package.json:

{
  "name": "gatsby-starter-default",
  "private": true,
  "description": "A simple starter to get up and developing quickly with Gatsby",
  "version": "0.1.0",
  "author": "Kyle Mathews <mathews.kyle@gmail.com>",
  "dependencies": {
    "gatsby": "^2.3.5",
    "gatsby-image": "^2.0.37",
    "gatsby-plugin-manifest": "^2.0.26",
    "gatsby-plugin-offline": "^2.0.25",
    "gatsby-plugin-react-helmet": "^3.0.11",
    "gatsby-plugin-sharp": "^2.0.32",
    "gatsby-source-filesystem": "^2.0.28",
    "gatsby-transformer-sharp": "^2.1.17",
    "prop-types": "^15.7.2",
    "react": "^16.8.6",
    "react-dom": "^16.8.6",
    "react-helmet": "^5.2.0"
  },
  "devDependencies": {
    "prettier": "^1.16.4"
  },
  "keywords": [
    "gatsby"
  ],
  "license": "MIT",
  "scripts": {
    "build": "gatsby build",
    "develop": "gatsby develop",
    "format": "prettier --write src/**/*.{js,jsx}",
    "start": "npm run develop",
    "serve": "gatsby serve",
    "test": "echo \"Write tests! -> https://gatsby.dev/unit-testing\""
  },
  "repository": {
    "type": "git",
    "url": "https://github.com/gatsbyjs/gatsby-starter-default"
  },
  "bugs": {
    "url": "https://github.com/gatsbyjs/gatsby/issues"
  }
}

As noted in the comments above the problem was that gatsby develop and gatsby build seemed to have different requirements. 如上面的评论所述,问题在于gatsby developgatsby build似乎有不同的要求。 While working with the bulld command es6's fetch command needs to be imported manually (boo). 在使用bulld命令时,需要手动导入es6的fetch命令(boo)。

This just meant adding the line 这只是意味着增加线

import 'isomorphic-fetch';

To all files calling fetch . 对所有文件调用fetch

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM