简体   繁体   中英

No index.html file after gatsby-cli build?

I'm experimenting with 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. I went to use gatsby build and it does produce a /public folder, however there's no "index.html" or even "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?

A ls of the /public directory returns:

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:

{
  "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. While working with the bulld command es6's fetch command needs to be imported manually (boo).

This just meant adding the line

import 'isomorphic-fetch';

To all files calling fetch .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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