Skip to content

Instantly share code, notes, and snippets.

@saitonakamura
Created February 19, 2018 21:02
Show Gist options
  • Save saitonakamura/643d6f7c4b02f56f5dd962e0d38eaaa5 to your computer and use it in GitHub Desktop.
Save saitonakamura/643d6f7c4b02f56f5dd962e0d38eaaa5 to your computer and use it in GitHub Desktop.
Next.js on Github Pages
const webpack = require('webpack')
const isProd = (process.env.NODE_ENV || 'production') === 'production'
const assetPrefix = isProd ? '/your-repository-name' : ''
module.exports = {
exportPathMap: () => ({
'/': { page: '/' },
'/page1': { page: '/page1' },
}),
assetPrefix: assetPrefix,
webpack: config => {
config.plugins.push(
new webpack.DefinePlugin({
'process.env.ASSET_PREFIX': JSON.stringify(assetPrefix),
}),
)
return config
},
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment