Skip to content

Instantly share code, notes, and snippets.

@littledian
Last active October 16, 2018 09:23
Show Gist options
  • Save littledian/a71b9f4b2224f6e0f486130ff0042d6c to your computer and use it in GitHub Desktop.
Save littledian/a71b9f4b2224f6e0f486130ff0042d6c to your computer and use it in GitHub Desktop.
const path = require('path')
const PrerenderSPAPlugin = require('prerender-spa-plugin')
const Renderer = PrerenderSPAPlugin.PuppeteerRenderer
module.exports = {
configureWebpack: config => {
if (process.env.NODE_ENV === 'production') {
// 为生产环境修改配置...
config.plugins.push(
new PrerenderSPAPlugin({
staticDir: path.join(__dirname, 'dist'),
routes: [ '/', '/about' ],
renderer: new Renderer({
inject: {
foo: 'bar'
},
headless: false,
renderAfterDocumentEvent: ''
})
})
)
} else {
// 为开发环境修改配置...
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment