web前端项目创建Vite-Project

2 篇文章 0 订阅
1 篇文章 0 订阅

Web框架-Web前端项目创建Vite-Project

Node.js*

即使曾经安装过也使用最新版node.js重新安装,自动覆盖。修改到合适分区,例如D:\。其他全部默认,无需安装Chocolatey。

windows是中文用户名可能会有影响。

NPM Settings

进入windows命令行模式,设置npm服务器使用aliyun镜像。复制以下命令,在控制台鼠标右键选择粘帖,回车执行
npm config set registry http://registry.npmmirror.com

Vite Project
https://staging-cn.vuejs.org/guide/quick-start.html#with-build-tools

在合适位置创建vue-workspace工作区目录,存放所有vue项目。

通过命令行,进入工作区,执行项目初始化命令。
npm init vue@latest
选择以下配置。

TypeScript/router/pinia/eslint/prettier

✔ Project name: … <your-project-name>
✔ Add TypeScript? … Yes
✔ Add JSX Support? … No
✔ Add Vue Router for Single Page Application development? … Yes
✔ Add Pinia for state management? … Yes
✔ Add Vitest for Unit testing? … No
✔ Add Cypress for both Unit and End-to-End testing? … No
✔ Add ESLint for code quality? … Yes
✔ Add Prettier for code formatting? … Yes

VS Vode

下载压缩版vscode,解压运行。安装volar/TypeScript Vue Plugin/eslint,3个插件,重启vs code。

打开项目目录,打开vs code控制台,crtl+`

在控制台视图(默认即是当前项目路径下),安装依赖。由于配置了国内镜像,下载速度会很快。依赖在100M以上

npm i

启动项目

npm run dev

结束运行,在控制台输入组合键

ctrl+c
eslint/prettier
以eslint检查代码规范,以prettier统一代码风格,并在保存文件时自动修复错误

创建,.prettierrc.json。单引号,无分号,不检测文件结束符格式

{
    "htmlWhitespaceSensitivity": "ignore",
    "singleQuote": true,
    "semi": false,
    "endOfLine": "auto"
}

修改.esintrc.cjs,添加规则

rules: {
    'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
    'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
    'vue/multi-word-component-names': 'off',
  },

当前项目.vscode目录下,创建settings.json。声明项目的vscode配置

{
  "editor.fontSize": 18,
  "window.zoomLevel": 1.0,
  "editor.wordWrap": "on", 
  "editor.codeActionsOnSave": {
    "source.fixAll.eslint": true,
  },
  "git.enableSmartCommit": true,
  "workbench.colorTheme": "Default Light+",
  "typescript.updateImportsOnFileMove.enabled": "always",
  "javascript.updateImportsOnFileMove.enabled": "always",
  "explorer.confirmDelete": false,
  "explorer.confirmDragAndDrop": false,
  "emmet.triggerExpansionOnTab": true,
}

进入项目
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

秋野樱

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值