From c8debfee309ff8c9054dcd70d7b0fae1b2d1b500 Mon Sep 17 00:00:00 2001 From: Ishaan Malhi Date: Wed, 3 Oct 2018 01:22:00 +0530 Subject: [PATCH] Add deploying-to-heroku.md --- docs/docs/deploying-to-heroku.md | 48 ++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 docs/docs/deploying-to-heroku.md diff --git a/docs/docs/deploying-to-heroku.md b/docs/docs/deploying-to-heroku.md new file mode 100644 index 0000000000000..6c57271b310f5 --- /dev/null +++ b/docs/docs/deploying-to-heroku.md @@ -0,0 +1,48 @@ +--- +title: Deploying to Heroku +--- +You can use the [heroku buildpack static](https://github.com/heroku/heroku-buildpack-static) to handle the static files of your site. + +Set the `heroku/node.js` and `heroku-buildpack-static` buildpacks on your application creating an `app.json` file on the root of your project. + +app.json: +``` +{ + "buildpacks": [ + { + "url": "heroku/nodejs" + }, + { + "url": "https://github.com/heroku/heroku-buildpack-static" + } + ] +} +``` + +Sometimes specifying buildpacks via the `app.json` file doesn’t work. If this is your case try to add them in the Heroku dashboard or via the CLI. + +Add a `heroku-postbuild` script in your `package.json`: + +package.json: +``` +{ + // ... + "scripts": { + // ... + "heroku-postbuild": "gatsby build" + // ... + } + // ... +} +``` +Finally, add a `static.json` file in the root of your project to define the directory where your static assets will be. You can check all the options for this file in the [heroku-buildpack-static](https://github.com/heroku/heroku-buildpack-static#configuration) configuration. +``` +{ + "root": "public/", + "headers": { + "/**.js": { + "Cache-Control": "public, max-age=0, must-revalidate" + } + } +} +```