基于vue cli3.0 搭建的项目,通过prerender-spa-plugin 插件进行预编。
其中配置文件vue.config.js 配置如下:
const path = require('path')
const PrerenderSPAPlugin = require('prerender-spa-plugin')
const Renderer = PrerenderSPAPlugin.PuppeteerRenderer
module.exports = {
// 配置文件,可以手动配置访问的端口、地址
devServer: {
// port: 8085, // 端口号
// host: '127.0.0.1',
// https: false // https:{type:Boolean}
disableHostCheck: true,
proxy: {
'/api': {
target: 'http://192.168.3.62:9095/', // 对应自己的接口
changeOrigin: true,
ws: true,
pathRewrite: {
'^/api': ''
}
}
}
},
configureWebpack: () => {
if (process.env.NODE_ENV !== 'production') return
return {
plugins: [
new PrerenderSPAPlugin({
// 生成文件的路径,也可以与webpakc打包的一致。
// 下面这句话非常重要!!!
// 这个