Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(boilerplate): create Vue apps with Vite #514

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft

Conversation

ghost
Copy link

@ghost ghost commented Sep 15, 2022

因为 @vue/cli 已经进入 Maintenance Mode 了,所以我试着把通过 lean new 创建 Vue 项目的工具换成了 create-vite。但现在遇到了一个小问题,就是由于以下这三种情况同时存在,导致如果开发者直接把通过 create-vite 创建的项目使用 lean deploy 进行部署(而不预先手动执行一次 npm install),会遇到因为云端环境缺少 vite 这一依赖而无法构建的错误:

  1. Vite 会把构建项目所需的 vite 和 @vitejs/plugin-vue 这两个依赖放入 devDependencies
  2. Vite 创建好项目后,不会自动运行 npm install,所以项目中默认只有 package.json,不会有 package-lock.json;
  3. 如果项目中不存在 package-lock.json,云引擎会使用 npm install --production 安装依赖,这意味着 devDependencies 中的依赖不会被安装。

如果我们假定多数开发者创建项目后会在部署之前自己执行一次 npm install(事实上 create-vite 创建好项目后会引导开发者手动运行一次 npm install),那么我们可能就不用太在意这个问题了。可能会存在少数开发者在创建项目后什么都不做就直接部署,但我不确定这部分开发者会有多少。我推测一部分开发者可能会因为想在开始开发项目之前先测试一下云引擎的部署功能所以这么做。

一些可能的解决方案:

  • 让 lean-cli 在创建好项目后自动执行一次 npm install
  • 让云引擎的云端环境默认提供 vite 和 @vitejs/plugin-vue。
  • 让云引擎在 package-lock.json 不存在的情况下使用 npm install 安装依赖,而非 npm install --production

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant