stereobooster / react-snap

👻 Zero-configuration framework-agnostic static prerendering for SPAs
MIT License
5.04k stars 391 forks source link

Not building all views / building views that are not requested #430

Open marcuszierke opened 4 years ago

marcuszierke commented 4 years ago

I ran into this issue when I checked out the less important pages of my project (e.g. the "Thank you" page after submitting a form). Apparently react-snap doesn't build all the pages when running react run build. This is my package.json:

{
  "name": "project-name",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "@contentful/rich-text-html-renderer": "^13.1.0",
    "@contentful/rich-text-react-renderer": "^13.2.0",
    "@contentful/rich-text-types": "^13.1.0",
    "contentful": "^7.5.0",
    "country-list": "^2.2.0",
    "font-awesome": "^4.7.0",
    "lunr": "^2.3.6",
    "markdown-to-jsx": "^6.10.3",
    "materialize-css": "^1.0.0",
    "node-fetch": "^2.6.0",
    "prop-types": "^15.7.2",
    "react": "^16.8.4",
    "react-dom": "^16.8.4",
    "react-helmet": "^5.2.1",
    "react-intl": "^2.8.0",
    "react-intl-cra": "^0.3.4",
    "react-intl-translations-manager": "^5.0.3",
    "react-router-dom": "^4.3.1",
    "react-router-hash-link": "^1.2.2",
    "react-scripts": "2.1.8",
    "react-share": "^3.0.1",
    "react-snapshot": "^1.3.0",
    "serve": "^11.1.0",
    "serve-handler": "^6.1.2",
    "uuid": "^3.3.3"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "postbuild": "react-snap",
    "clean": "rm -rf build/*",
    "start:dev": "node config/webpack-dev-server.js",
    "start:prod": "npm build; serve build",
    "test": "react-scripts test",
    "eject": "react-scripts eject",
    "lint": "eslint src -c .eslintrc --ext js,jsx"
  },
  "eslintConfig": {
    "extends": "react-app"
  },
  "browserslist": [
    ">0.2%",
    "not dead",
    "not ie <= 11",
    "not op_mini all"
  ],
  "devDependencies": {
    "@babel/core": "^7.4.0",
    "@babel/polyfill": "^7.4.0",
    "@babel/preset-env": "^7.4.2",
    "@babel/preset-react": "^7.0.0",
    "babel-loader": "^8.0.5",
    "css-loader": "^2.1.1",
    "dotenv": "^8.2.0",
    "ember-cli-materialize": "^0.22.0",
    "eslint-config-airbnb": "^17.1.0",
    "eslint-config-prettier": "^4.1.0",
    "eslint-import-resolver-webpack": "^0.11.0",
    "eslint-loader": "^2.1.2",
    "eslint-plugin-import": "^2.16.0",
    "eslint-plugin-jsx-a11y": "^6.2.1",
    "eslint-plugin-prettier": "^3.0.1",
    "eslint-plugin-react": "^7.12.4",
    "extract-text-webpack-plugin": "^4.0.0-beta.0",
    "file-loader": "^3.0.1",
    "html-webpack-plugin": "^3.2.0",
    "node-sass": "^4.11.0",
    "path": "^0.12.7",
    "prettier": "^1.16.4",
    "react-hot-loader": "^4.8.0",
    "react-snap": "^1.23.0",
    "sass": "*",
    "sass-loader": "^7.1.0",
    "style-loader": "^0.23.1",
    "uglifyjs-webpack-plugin": "^2.1.2",
    "webpack-command": "^0.4.2",
    "webpack-merge": "^4.2.1"
  },
  "reactSnap": {
    "puppeteerArgs": [
      "--no-sandbox",
      "--disable-setuid-sandbox"
    ]
  }
}

I figured that not even the HomePage is in the build folder but for some reason it works, 3 views are definitely missing, at least 5 views are in the build folder that shouldn't be there.

This is the structure of the src folder:

Screenshot 2019-12-17 at 13 26 56

I couldn't find anything about structuring in the docs, is there a certain way views have to be organised so the will be recognised during the build process? Did anybody have experience with this issue as well?

eddievlagea commented 4 years ago

DId you find a solution for this?

marcuszierke commented 4 years ago

Just a workaround by adding hidden slugs to the project so react-snap finds them while building