Gatsby: how can I deploy the sites to a CDN?

Created on 5 Jul 2017  Â·  2Comments  Â·  Source: gatsbyjs/gatsby

hi, I want to deploy all files(including pics/js/css/font) except index.html to my CDN, e.g. http://cdn.example.com, but deploy index.html to my main site: http://www.example.com. Is it possible? I work around for several hours, including set

pathPrefix: 'http://cdn.example.com'

in gatsby-config.js.
or modify webpack config in gatsby-node.js

exports.modifyWebpackConfig = ({config, stage}) => {
  config.merge({
    output: {
      publicPath: 'http://localhost:50000000000/',
    }
  })

  return config;
}

In create-react-app, I just need to set PUBLIC_URL and in webpack I just need to set publicPath in output.

Is there sth I missing? Any help is welcome. Thanks~
I use https://github.com/gatsbyjs/gatsby-starter-blog/tree/1.0 as a starter, so the package.json file is the same.

Most helpful comment

Netlify is a good option if you're looking for something hosted. They also have an auto-deploy feature that knows how to build Gatsby sites so you don't have to set up CI.

All 2 comments

With a static site you really want to deploy everything to a CDN. You're
site is significantly faster this way as html can be loaded from the CDN as
well as assets and you don't have to do multiple SSL negotiations. Perhaps
we can add support for this style of deployment but in the meantime,
there's plenty of static hosts that'll put everything for you on a CDN.

On Tue, Jul 4, 2017, 8:59 PM magicly notifications@github.com wrote:

hi, I want to deploy all files(including pics/js/css/font) except
index.html to my CDN, e.g. http://cdn.example.com, but deploy index.html
to my main site: http://www.example.com. Is it possible? I work around
for several hours, including set

pathPrefix: 'http://cdn.example.com'

in gatsby-config.js.
or modify webpack config in gatsby-node.js

exports.modifyWebpackConfig = ({config, stage}) => {
config.merge({
output: {
publicPath: 'http://localhost:50000000000/',
}
})

return config;
}

In create-react-app, I just need to set PUBLIC_URL and in webpack I just
need to set publicPath in output.

Is there sth I missing? Any help is welcome. Thanks~
I use https://github.com/gatsbyjs/gatsby-starter-blog/tree/1.0 as a
starter, so the package.json file is the same.

—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/gatsbyjs/gatsby/issues/1369, or mute the thread
https://github.com/notifications/unsubscribe-auth/AAEVhxjGJ4biLERltkzcPTt3-CpCdBVoks5sKwoSgaJpZM4ON1Y5
.

Netlify is a good option if you're looking for something hosted. They also have an auto-deploy feature that knows how to build Gatsby sites so you don't have to set up CI.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

andykais picture andykais  Â·  3Comments

rossPatton picture rossPatton  Â·  3Comments

theduke picture theduke  Â·  3Comments

ferMartz picture ferMartz  Â·  3Comments

3CordGuy picture 3CordGuy  Â·  3Comments