const config = { base: './', // index.html文件所在位置 root: './', // js导入的资源路径,src resolve: { alias, }, define: { 'process.env': {} }, server: { // 如果使用docker-compose开发模式,设置为false open: true, port: process.env.VITE_CLI_PORT, proxy: { // 把key的路径代理到target位置 // detail: https://cli.vuejs.org/config/#devserver-proxy [process.env.VITE_BASE_API]: { // 需要代理的路径 例如 '/api' target: `${process.env.VITE_BASE_PATH}/`, // 代理到 目标路径 changeOrigin: true, rewrite: path => path.replace(new RegExp('^' + process.env.VITE_BASE_API), ''), }, [process.env.VITE_BASE_EXPORT_API]: { // 需要代理的路径 例如 '/api' target: `${process.env.VITE_BASE_REPORTAPI}/`, // 代理到 目标路径 changeOrigin: true, rewrite: path => path.replace(new RegExp('^' + process.env.VITE_BASE_EXPORT_API), ''), }, }, }, build: { target: 'es2017', minify: 'terser', // 是否进行压缩,boolean | 'terser' | 'esbuild',默认使用terser manifest: false, // 是否产出manifest.json sourcemap: false, // 是否产出sourcemap.json outDir: 'dist', // 产出目录 // rollupOptions, }, esbuild, optimizeDeps, plugins: [ GvaPositionServer(), GvaPosition(), legacyPlugin({ targets: ['Android > 39', 'Chrome >= 60', 'Safari >= 10.1', 'iOS >= 10.3', 'Firefox >= 54', 'Edge >= 15'], }), vuePlugin(), [Banner(`\n Build based on gin-vue-admin \n Time : ${timestamp}`)] ], css: { preprocessorOptions: { scss: { additionalData: `@use "@/style/element/index.scss" as *;`, } } }, } 请帮我修改以上代码,当build打包时,前端页面url新增VITE_PUBLIC_PATH= '/devOnlineStatus/'前缀
时间: 2024-04-18 16:31:27 浏览: 163
const config = {
base: './', // index.html文件所在位置
root: './', // js导入的资源路径,src
resolve: {
alias,
},
define: {
'process.env': {}
},
server: {
// 如果使用docker-compose开发模式,设置为false
open: true,
port: process.env.VITE_CLI_PORT,
proxy: {
// 把key的路径代理到target位置
// detail: https://cli.vuejs.org/config/#devserver-proxy
[process.env.VITE_BASE_API]: { // 需要代理的路径 例如 '/api'
target: `${process.env.VITE_BASE_PATH}/`, // 代理到 目标路径
changeOrigin: true,
rewrite: path => path.replace(new RegExp('^' + process.env.VITE_BASE_API), ''),
},
[process.env.VITE_BASE_EXPORT_API]: { // 需要代理的路径 例如 '/api'
target: `${process.env.VITE_BASE_REPORTAPI}/`, // 代理到 目标路径
changeOrigin: true,
rewrite: path => path.replace(new RegExp('^' + process.env.VITE_BASE_EXPORT_API), ''),
},
},
},
build: {
target: 'es2017',
minify: 'terser', // 是否进行压缩,boolean | 'terser' | 'esbuild',默认使用terser
manifest: false, // 是否产出manifest.json
sourcemap: false, // 是否产出sourcemap.json
outDir: 'dist', // 产出目录
// rollupOptions,
},
esbuild,
optimizeDeps,
plugins: [
GvaPositionServer(),
GvaPosition(),
legacyPlugin({
targets: ['Android > 39', 'Chrome >= 60', 'Safari >= 10.1', 'iOS >= 10.3', 'Firefox >= 54', 'Edge >= 15'],
}),
vuePlugin(),
[Banner(`\n Build based on gin-vue-admin \n Time : ${timestamp}`)]
],
css: {
preprocessorOptions: {
scss: {
additionalData: `@use "@/style/element/index.scss" as *;`,
}
}
},
}
// Add VITE_PUBLIC_PATH to the define object when building
if (command === 'build') {
config.define['process.env.VITE_PUBLIC_PATH'] = "'/devOnlineStatus/'"
}
return config
阅读全文