Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
CFFP-HB
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Chao Sun
CFFP-HB
Commits
06cc4871
Commit
06cc4871
authored
Jul 24, 2025
by
zhangxingmin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
push
parent
844bd15d
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
61 additions
and
36 deletions
+61
-36
main.js
+13
-18
vite.config.js
+48
-18
No files found.
main.js
View file @
06cc4871
import
App
from
'./App.vue'
;
// main.js
// #ifndef VUE3
import
Vue
from
'vue'
import
Vue
from
'vue'
import
App
from
'./App.vue'
// 确保 App 组件的类型正确
App
.
mpType
=
'app'
App
.
mpType
=
'app'
// 创建 Vue 实例
const
app
=
new
Vue
({
const
app
=
new
Vue
({
...
App
render
:
h
=>
h
(
App
)
})
})
app
.
$mount
()
// #endif
// #ifdef VUE3
// 挂载应用
// import { createSSRApp } from 'vue'
app
.
$mount
()
// export function createApp() {
// const app = createSSRApp(App)
// return {
// app
// }
// }
// #endif
//#ifdef H5
// H5 环境下设置 firstEntryUrl
window
.
sessionStorage
.
setItem
(
'firstEntryUrl'
,
window
.
location
.
href
.
split
(
'#'
)[
0
])
if
(
process
.
env
.
VUE_APP_PLATFORM
===
'h5'
)
{
// #endif
window
.
sessionStorage
.
setItem
(
'firstEntryUrl'
,
window
.
location
.
href
.
split
(
'#'
)[
0
])
}
vite.config.js
View file @
06cc4871
...
@@ -3,41 +3,71 @@ import { createVuePlugin } from 'vite-plugin-vue2'
...
@@ -3,41 +3,71 @@ import { createVuePlugin } from 'vite-plugin-vue2'
import
path
from
'path'
import
path
from
'path'
export
default
defineConfig
({
export
default
defineConfig
({
//
路径前缀,与 Nginx 配置匹配
//
根路径配置,与 Nginx 保持一致
base
:
'/'
,
base
:
'/'
,
plugins
:
[
createVuePlugin
()],
plugins
:
[
// 配置 Vue 2 插件
createVuePlugin
({
vueTemplateOptions
:
{
compilerOptions
:
{
// 针对 Vue 2 的模板编译选项
whitespace
:
'condense'
}
}
})
],
resolve
:
{
resolve
:
{
extensions
:
[
'.vue'
,
'.js'
,
'.ts'
,
'.json'
],
extensions
:
[
'.vue'
,
'.js'
,
'.ts'
,
'.json'
],
alias
:
{
alias
:
{
'@'
:
path
.
resolve
(
__dirname
),
// 指向 src 目录(如果你的项目结构有 src 目录)
'@api'
:
path
.
resolve
(
__dirname
,
'api'
)
'@'
:
path
.
resolve
(
__dirname
,
'src'
),
'@api'
:
path
.
resolve
(
__dirname
,
'api'
),
// 确保 Vue 2 正确解析
'vue'
:
'vue/dist/vue.runtime.common.js'
}
}
},
},
//
//
开发服务器配置
// 开发服务器配置
//
server: {
server
:
{
//
port: 8080,
port
:
8080
,
//
proxy: {
proxy
:
{
//
// 代理后端 API 请求
// 代理后端 API 请求
//
'/cffpApi': {
'/cffpApi'
:
{
// target: 'http://localhost:8080',
target
:
'http://localhost:8080'
,
// 修改为实际后端地址
//
changeOrigin: true,
changeOrigin
:
true
,
//
rewrite: (path) => path.replace(/^\/cffpApi/, '')
rewrite
:
(
path
)
=>
path
.
replace
(
/^
\/
cffpApi/
,
''
)
//
}
}
//
}
}
//
},
},
build
:
{
build
:
{
outDir
:
'dist'
,
// 输出到 dist 根目录(而非 dist/cffp)
outDir
:
'dist'
,
assetsDir
:
'assets'
,
assetsDir
:
'assets'
,
// 生成 manifest 文件,便于追踪资源
manifest
:
true
,
// 压缩代码
minify
:
'terser'
,
rollupOptions
:
{
rollupOptions
:
{
output
:
{
output
:
{
// 自定义输出文件名
entryFileNames
:
'assets/[name].[hash].js'
,
entryFileNames
:
'assets/[name].[hash].js'
,
chunkFileNames
:
'assets/[name].[hash].js'
,
chunkFileNames
:
'assets/[name].[hash].js'
,
assetFileNames
:
'assets/[name].[hash].[ext]'
assetFileNames
:
'assets/[name].[hash].[ext]'
,
// 手动分割代码
manualChunks
(
id
)
{
if
(
id
.
includes
(
'node_modules'
))
{
return
'vendor'
;
// 将第三方依赖打包到 vendor
}
}
}
}
}
}
},
// 生产环境移除 console
esbuild
:
{
drop
:
[
'console'
,
'debugger'
]
}
}
})
})
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment