Vue 3 生产部署
Vue 3 production deployment
我目前正在部署我的 Vue 3 项目(使用 Laravel API 后端),我在部署时遇到了一些问题。
我想做的是,我使用 git-ftp 将我的 Vue 项目推送到 production 服务器,然后我 运行 npm install
和 npm run build
来构建应用程序。我收到一个错误:
FATAL ERROR: MarkCompactCollector: young object promotion failed Allocation failed - JavaScript heap out of memory
我读过一些类似的问题,其中一种可能的方法是使用命令为 Vue 分配更多内存
npx --max_old_space_size=4095 vue-cli-service build --modern
然而这产生了同样的错误。这些是我的 package.json 依赖项(包括开发)
"dependencies": {
"@fullcalendar/core": "^5.10.1",
"@fullcalendar/daygrid": "^5.10.1",
"@fullcalendar/interaction": "^5.10.1",
"@fullcalendar/vue3": "^5.10.1",
"@popperjs/core": "^2.9.3",
"@vue/cli-plugin-babel": "~4.5.0",
"@vue/cli-service": "~4.5.0",
"@vue/compiler-sfc": "^3.0.0",
"axios": "^0.21.1",
"bootstrap": "^5.1.0",
"core-js": "^3.6.5",
"datatables.net": "^1.11.3",
"datatables.net-dt": "^1.11.3",
"dotenv": "^10.0.0",
"jquery": "^3.6.0",
"module": "^1.2.5",
"moment": "^2.29.1",
"vue": "^3.0.0",
"vue-axios": "^3.2.5",
"vue-plugin-load-script": "git://github.com/tserkov/vue-plugin-load-script.git#vue3",
"vue-router": "^4.0.11",
"vuex": "^4.0.2",
"vuex-persistedstate": "^4.0.0",
"webpack": "^4.3.0"
},
"devDependencies": {
"babel-eslint": "^10.1.0",
"gulp": "^4.0.2",
"gulp-clean-css": "^4.3.0",
"gulp-concat": "^2.6.1",
"gulp-minify": "^3.1.0",
"gulp-sass": "^5.0.0",
"prettier": "^2.2.1",
"resolve-url-loader": "^4.0.0",
"sass": "^1.43.2",
"sass-loader": "^12.1.0"
}
是否有可能,错误的原因是因为我 运行 在生产中使用它?
如果是,我的其他部署选项是什么?
我只需要能够使用 git 命令将其推送到 git 存储库,然后将其推送到生产环境并构建它。
我们还没弄明白。
相反,我们在 GitLab 中使用了 runner 选项,这样当我们合并到 develop/master 时,脚本会自动运行并且:
- 构建 Vue 项目
- 将内容文件夹推送到 ftp,同时将其重命名为 dist
我目前正在部署我的 Vue 3 项目(使用 Laravel API 后端),我在部署时遇到了一些问题。
我想做的是,我使用 git-ftp 将我的 Vue 项目推送到 production 服务器,然后我 运行 npm install
和 npm run build
来构建应用程序。我收到一个错误:
FATAL ERROR: MarkCompactCollector: young object promotion failed Allocation failed - JavaScript heap out of memory
我读过一些类似的问题,其中一种可能的方法是使用命令为 Vue 分配更多内存
npx --max_old_space_size=4095 vue-cli-service build --modern
然而这产生了同样的错误。这些是我的 package.json 依赖项(包括开发)
"dependencies": {
"@fullcalendar/core": "^5.10.1",
"@fullcalendar/daygrid": "^5.10.1",
"@fullcalendar/interaction": "^5.10.1",
"@fullcalendar/vue3": "^5.10.1",
"@popperjs/core": "^2.9.3",
"@vue/cli-plugin-babel": "~4.5.0",
"@vue/cli-service": "~4.5.0",
"@vue/compiler-sfc": "^3.0.0",
"axios": "^0.21.1",
"bootstrap": "^5.1.0",
"core-js": "^3.6.5",
"datatables.net": "^1.11.3",
"datatables.net-dt": "^1.11.3",
"dotenv": "^10.0.0",
"jquery": "^3.6.0",
"module": "^1.2.5",
"moment": "^2.29.1",
"vue": "^3.0.0",
"vue-axios": "^3.2.5",
"vue-plugin-load-script": "git://github.com/tserkov/vue-plugin-load-script.git#vue3",
"vue-router": "^4.0.11",
"vuex": "^4.0.2",
"vuex-persistedstate": "^4.0.0",
"webpack": "^4.3.0"
},
"devDependencies": {
"babel-eslint": "^10.1.0",
"gulp": "^4.0.2",
"gulp-clean-css": "^4.3.0",
"gulp-concat": "^2.6.1",
"gulp-minify": "^3.1.0",
"gulp-sass": "^5.0.0",
"prettier": "^2.2.1",
"resolve-url-loader": "^4.0.0",
"sass": "^1.43.2",
"sass-loader": "^12.1.0"
}
是否有可能,错误的原因是因为我 运行 在生产中使用它? 如果是,我的其他部署选项是什么?
我只需要能够使用 git 命令将其推送到 git 存储库,然后将其推送到生产环境并构建它。
我们还没弄明白。
相反,我们在 GitLab 中使用了 runner 选项,这样当我们合并到 develop/master 时,脚本会自动运行并且:
- 构建 Vue 项目
- 将内容文件夹推送到 ftp,同时将其重命名为 dist