vue项目打包后的index.html打开空白问题解决

294 阅读1分钟

以下是vue2项目中配置

主要是需要指定静态资源目录assetsDir: 'static'

const path = require('path')
const fs = require('fs')

module.exports = {
	devServer: {
		proxy: {
			'/api': {
				target: 'http://127.0.0.1:8888',
				changeOrigin: true,
				ws: false,
				pathRewrite: {
					'^/api': ''
				}
			}
		}
	},
	outputDir: path.resolve(__dirname, './dist'), // 指定输出目录 
	publicPath: './', // 修改 assetsPublicPath 为当前目录 
	assetsDir: 'static' // 指定静态资源目录
}