Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

no index.html file in public folder after building #21843

Closed
barbalex opened this issue Feb 28, 2020 · 4 comments
Closed

no index.html file in public folder after building #21843

barbalex opened this issue Feb 28, 2020 · 4 comments
Labels
type: bug An issue or pull request relating to a bug in Gatsby

Comments

@barbalex
Copy link

barbalex commented Feb 28, 2020

Description

After running gatsby clean && gatsby build the public folder contains no index.html file. Which leads to the project not working when served by a static server (in my case caddy on docker).

Steps to reproduce

  1. clone the project: https://github.com/barbalex/bb2 and cd into it
  2. yarn
  3. yarn build
  4. check in the public folder

Expected result

There should be an index.html file.

Actual result

There is none.
There is one in the offline-plugin-app-shell-fallback folder though.

Environment

$ yarn gatsby info --clipboard                                                                                     
yarn run v1.21.1                                                                                                   
$ C:\Users\alexa\bb2\node_modules\.bin\gatsby info --clipboard                                                     
                                                                                                                   
  System:                                                                                                          
    OS: Windows 10 10.0.18363                                                                                      
    CPU: (16) x64 Intel(R) Core(TM) i9-9900K CPU @ 3.60GHz                                                         
  Binaries:                                                                                                        
    Node: 13.7.0 - C:\Users\alexa\AppData\Local\Temp\yarn--1582924389588-0.9135959853559317\node.CMD               
    Yarn: 1.21.1 - C:\Users\alexa\AppData\Local\Temp\yarn--1582924389588-0.9135959853559317\yarn.CMD               
    npm: 6.13.6 - C:\Program Files\nodejs\npm.CMD                                                                  
  Languages:                                                                                                       
    Python: 2.7.17                                                                                                 
  Browsers:                                                                                                        
    Edge: 44.18362.449.0                                                                                           
  npmPackages:                                                                                                     
    gatsby: 2.19.23 => 2.19.23                                                                                     
    gatsby-plugin-eslint: 2.0.8 => 2.0.8                                                                           
    gatsby-plugin-manifest: 2.2.42 => 2.2.42                                                                       
    gatsby-plugin-offline: 3.0.35 => 3.0.35                                                                        
    gatsby-plugin-react-helmet: 3.1.22 => 3.1.22                                                                   
    gatsby-plugin-sharp: 2.4.5 => 2.4.5                                                                            
    gatsby-plugin-styled-components: 3.1.19 => 3.1.19                                                              
    gatsby-source-filesystem: 2.1.48 => 2.1.48                                                                     
    gatsby-transformer-sharp: 2.3.16 => 2.3.16                                                                                                                                                                        

My best guess

I just converted this project from a create-react-app project. Then I kept the router in the App.js file instead of using the pages folder, because that seemed like a comfortable shortcut to not have to bother with achieving all the routing in pages: https://github.com/barbalex/bb2/blob/60b908670eb751a44f3d78a51f53aaedd625681e/src/App.js#L86-L101

Works fine in dev mode and even when running gatsby serve.

Probably this is not expected and breaks in the build?

@barbalex barbalex added the type: bug An issue or pull request relating to a bug in Gatsby label Feb 28, 2020
@barbalex
Copy link
Author

Yep, my guess was correct: Gatsby seems to build no index.html file if there is no index.js file in the pages folder.

I changed my app to include that index.js file and now it is building the index.html file.

@KaranKaira
Copy link

@barbalex my project had index.js file in the src/pages/ folder but even then index.html didnt got created.

@amalitsky
Copy link
Contributor

Still seems like a valid bug to me - what if I am creating index page programmatically or using a redirect?

@m4thieulavoie
Copy link

Just came across this too, and creating an index.tsx under src/pages did the trick as pointed out by @barbalex . What's funny is that this new index is a dummy page, as gatsby redirects me to my actual index page once the scripts are loaded.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug An issue or pull request relating to a bug in Gatsby
Projects
None yet
Development

No branches or pull requests

4 participants