前端启动成功
This commit is contained in:
46
schoolNewsWeb/vue.config.js
Normal file
46
schoolNewsWeb/vue.config.js
Normal file
@@ -0,0 +1,46 @@
|
||||
import { defineConfig } from '@vue/cli-service'
|
||||
|
||||
export default defineConfig({
|
||||
transpileDependencies: true,
|
||||
publicPath: '/schoolNewsWeb/',
|
||||
outputDir: 'dist',
|
||||
assetsDir: 'static',
|
||||
|
||||
chainWebpack: (config) => {
|
||||
// 设置环境变量
|
||||
config.plugin('define').tap((definitions) => {
|
||||
Object.assign(definitions[0], {
|
||||
'process.env.BASE_URL': JSON.stringify('/schoolNewsWeb/'),
|
||||
'process.env.VITE_API_BASE_URL': JSON.stringify('/api'),
|
||||
'process.env.VITE_APP_TITLE': JSON.stringify('校园新闻管理系统'),
|
||||
})
|
||||
return definitions
|
||||
})
|
||||
|
||||
// 设置静态资源路径
|
||||
config.output.set('publicPath', '/schoolNewsWeb/')
|
||||
},
|
||||
|
||||
devServer: {
|
||||
host: '0.0.0.0',
|
||||
port: 8080,
|
||||
open: true,
|
||||
hot: true,
|
||||
historyApiFallback: {
|
||||
rewrites: [
|
||||
{ from: /^\/schoolNewsWeb/, to: '/schoolNewsWeb/index.html' }
|
||||
]
|
||||
},
|
||||
proxy: {
|
||||
'/api': {
|
||||
target: 'http://127.0.0.1:8081/schoolNewsServ',
|
||||
changeOrigin: true,
|
||||
pathRewrite: { '^/api': '' },
|
||||
logLevel: 'debug',
|
||||
onProxyReq: (proxyReq, req, res) => {
|
||||
console.log('代理请求:', req.method, req.url, '->', proxyReq.path);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user