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

Large public folder on build #2923

Closed
gilesbutler opened this issue Nov 15, 2017 · 7 comments · May be fixed by tejzpr/gatsby#61
Closed

Large public folder on build #2923

gilesbutler opened this issue Nov 15, 2017 · 7 comments · May be fixed by tejzpr/gatsby#61

Comments

@gilesbutler
Copy link

Hi Guys,

My public folder came out at 83mb! Is it normal for a Gatsby project to be so large? Is there anything I can do to bring that down as the upload to S3 is pretty slow.

I don't have any images in the site apart from a few tiny SVG files. Everything else is just code so it feels like something isn't quite right.

Any ideas?

Thanks

@gilesbutler
Copy link
Author

Ooops sorry just seen the guidelines for posting here.

Gatsby version: ^1.9.108,
node.js version: 6.9.2
OS version: OSX 10.13.1 (17B48)

package.json

{
  "name": "pipeline-social",
  "description": "Pipeline Social Gatsby Site",
  "version": "1.0.0",
  "author": "Giles Butler <[email protected]>",
  "dependencies": {
    "auth0-js": "^8.11.2",
    "fullpage-react": "^3.0.9",
    "gatsby": "^1.9.108",
    "gatsby-link": "^1.6.24",
    "gatsby-plugin-react-helmet": "^1.0.8",
    "gatsby-plugin-styled-components": "^2.0.2",
    "gatsby-plugin-typography": "^1.7.10",
    "gatsby-source-wordpress": "^2.0.36",
    "react-burger-menu": "^2.1.11",
    "react-icons": "^2.2.7",
    "react-responsive": "^3.0.0",
    "rebass": "^1.0.4",
    "scroll-to-element": "^2.0.0",
    "styled-components": "2.2.0"
  },
  "keywords": ["gatsby"],
  "license": "MIT",
  "main": "n/a",
  "scripts": {
    "build": "gatsby build",
    "develop": "gatsby develop",
    "format":
      "prettier --trailing-comma es5 --no-semi --single-quote --write \"src/**/*.js\"",
    "test": "echo \"Error: no test specified\" && exit 1",
    "TEST-deploy":
      "s3cmd sync public/* s3://lp.pipeline.social --no-check-certificate --delete-removed && echo '🚀  Deployed to Test!'"
  },
  "devDependencies": {
    "babel-eslint": "^8.0.2",
    "eslint": "^4.11.0",
    "eslint-config-prettier": "^2.7.0",
    "eslint-plugin-import": "^2.8.0",
    "eslint-plugin-jsx-a11y": "^6.0.2",
    "eslint-plugin-prettier": "^2.3.1",
    "eslint-plugin-react": "^7.4.0",
    "prettier": "^1.8.2"
  }
}

gatsby-config.js

module.exports = {
  siteMetadata: {
    title: `Title 👋 `
  },
  plugins: [
    `gatsby-plugin-styled-components`,
    `gatsby-plugin-react-helmet`,
    {
      resolve: `gatsby-plugin-typography`,
      options: {
        pathToConfigModule: `src/utils/typography.js`
      }
    }
  ]
};

gatsby-node.js

exports.modifyWebpackConfig = ({ config, stage }) => {
  if (stage === "build-html") {
    config.loader("null", {
      test: /scroll-to-element/,
      loader: "null-loader"
    });
  }

  return config;
};

Thanks

@KyleAMathews
Copy link
Contributor

Yeah does seem a bit large. A fresh build of gatsbyjs.org is ~51mb. Perhaps you've done quite a few builds now and accumulated some cruft? Gatsby deliberately doesn't delete anything on builds other than HTML as keeping old files around can be handy as someone can leave a site open and still be requesting resources from many builds ago.

@gilesbutler
Copy link
Author

Thanks @KyleAMathews :) good to know I'm not too far off but I only built for the first time last night 🤔 I had a bunch of errors that I fixed so have probably tried to build about 10-15 times whilst fixing them. Would that be causing it? What's the recommended way to clear out the cruft as this is a brand new site so we don't have to worry about old resources being requested.

@KyleAMathews
Copy link
Contributor

KyleAMathews commented Nov 15, 2017 via email

@gilesbutler
Copy link
Author

@KyleAMathews too simple 😂

@PolGuixe
Copy link
Contributor

PolGuixe commented Mar 28, 2019

@KyleAMathews what should be the size the public folder? I know it depends on the site, resources used, etc. but we have a quite simple site with some images that once build -clean build in CI/CD- the public folder goes up to 450MB. All that is due to the static folder which contains the different versions of the images. Is it normal? have you seen sites this big?

Is there a way to reduce this size? Less image versions maybe?

@KyleAMathews
Copy link
Contributor

It's 100% site dependent. You can run something like du -f public/ in your terminal to see what's taking the space.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants