<output id="qn6qe"></output>

    1. <output id="qn6qe"><tt id="qn6qe"></tt></output>
    2. <strike id="qn6qe"></strike>

      亚洲 日本 欧洲 欧美 视频,日韩中文字幕有码av,一本一道av中文字幕无码,国产线播放免费人成视频播放,人妻少妇偷人无码视频,日夜啪啪一区二区三区,国产尤物精品自在拍视频首页,久热这里只有精品12

      Vite 構建一個 Vue3 TypeScript 項目

      Vite 構建一個 Vue3 TypeScript 項目

      測試平臺(2022年09月07日)

      Microsoft Windows [版本 10.0.22000.856]
      (c) Microsoft Corporation。保留所有權利。
      
      C:\Users\test>node -v
      v16.13.0
      
      C:\Users\test>npm -v
      8.1.0
      

      一、使用 vite 模板創建項目

      1. 使用模板初始化項目

      npm create vite@latest my-vue-app -- --template vue-ts
      

      2. 關聯 Git 倉庫

      git init
      git add .
      git commit -m "first commit"
      git remote add origin <GIT_HTTP_URL>
      git push -u origin "master"
      

      3. 安裝基礎依賴

      # node 聲明
      npm i @types/node -D
      
      # 開發插件
      npm i vite-plugin-style-import -D
      
      # 項目依賴
      npm i sass pinia vue-router -S
      

      二、配置 vite.config.ts

      import { fileURLToPath, URL } from "node:url";
      
      import { defineConfig } from "vite";
      import vue from "@vitejs/plugin-vue";
      import {
        createStyleImportPlugin,
        NutuiResolve,
      } from "vite-plugin-style-import";
      
      // https://vitejs.dev/config/
      export default defineConfig({
        base: "/",
        build: {
          outDir: "build",
          sourcemap: true,
        },
        plugins: [
          vue(),
          createStyleImportPlugin({
            resolves: [NutuiResolve()],
          }),
        ],
        resolve: {
          alias: {
            "@": fileURLToPath(new URL("./src", import.meta.url)),
          },
        },
        css: {
          preprocessorOptions: {
            scss: {
              additionalData:
                "@import './src/styles/_var.scss';@import './src/styles/_mixins.scss';@import './src/styles/_common.scss';",
            },
          },
        },
        server: {
          port: 9527,
          proxy: {
            "/api": {
              target: "https://api.test.com",
              changeOrigin: true,
              rewrite: (path) => path.replace(/^\/api/, ""),
            },
          },
        },
      })
      

      配置 tsconfig.json

      {
        "compilerOptions": {
          ...
          "paths": {
            "@/*": ["./src/*"]
          }
        },
        ...
      }
      

      三、Git Hook

      進行此步時請先確保當前項目已經關聯 Git 倉庫,否則會拋出類似 fatal: not a git repository 的錯誤。

      3.1 安裝 prettier 、ESLint 以及 husky

      3.1.1 安裝 prettier

      npm i prettier -D
      npx mrm@2 lint-staged
      

      3.1.2 安裝 eslint

      npm i eslint -D
      npm init @eslint/config
      # √ How would you like to use ESLint? · problems
      # √ What type of modules does your project use? · esm
      # √ Which framework does your project use? · vue
      # √ Does your project use TypeScript? · Yes
      # √ Where does your code run? · browser
      # √ What format do you want your config file to be in? · JSON
      # The config that you've selected requires the following dependencies:
      #
      # eslint-plugin-vue@latest @typescript-eslint/eslint-plugin@latest @typescript-# eslint/parser@latest
      # √ Would you like to install them now? · Yes
      # √ Which package manager do you want to use? · npm
      # Installing eslint-plugin-vue@latest, @typescript-eslint/eslint-plugin@latest, @typescript-eslint/parser@latest
      #
      # added 22 packages in 3s
      # Successfully created .eslintrc.json file in C:\Workspace\Test\my-vue-app
      

      3.1.3 配置 .eslintrc.json

      {
        "env": {
          "browser": true,
          "es2021": true
        },
        "extends": [
          "eslint:recommended",
          "plugin:vue/vue3-essential",
          "plugin:@typescript-eslint/recommended"
        ],
        "overrides": [],
        "parser": "vue-eslint-parser",
        "parserOptions": {
          "ecmaVersion": "latest",
          "parser": "@typescript-eslint/parser",
          "sourceType": "module"
        },
        "plugins": ["vue", "@typescript-eslint"],
        "rules": {
          "vue/multi-word-component-names": 0
        }
      }
      

      3.2 安裝 commitlint

      npm install --save-dev @commitlint/config-conventional @commitlint/cli
      

      在根目錄下新建文件.commitlintrc.json

      {
        "extends": ["@commitlint/config-conventional"],
        "rules": {
          "type-enum": [
            2,
            "always",
            ["fix", "feat", "docs", "style", "refactor", "test", "chore", "revert"]
          ]
        }
      }
      

      3.3 配置 pre-commit 鉤子

      首先刪除.husky/pre-commit文件,然后執行下方命令:

      npx husky add .husky/pre-commit "npx --no-install lint-staged"
      

      3.4 配置 commit-msg 鉤子

      npx husky add .husky/commit-msg 'npx --no -- commitlint --edit "$1"'
      

      編輯package.json,添加以下配置:

      "lint-staged": {
        "*.{vue,ts,tsx,js,jsx}": [
          "eslint --fix",
          "prettier --write"
        ],
        "*.{html,css,scss,md}": [
          "prettier --write"
        ]
      }
      

      測試一下 commit 信息:

      測試一下提交:

      可以看到代碼被自動格式化了。

      四、源碼

      The End. Last Updated by Jimmy, 8 Sep 2022.

      posted @ 2022-09-08 17:10  古寶只  閱讀(361)  評論(0)    收藏  舉報
      主站蜘蛛池模板: 亚洲色大成网站www看下面| 色综合一本到久久亚洲91| 国产精品第一区亚洲精品| 天堂久久久久VA久久久久| 永登县| 亚洲香蕉网久久综合影视| 亚洲一区二区啊射精日韩| 亚洲日韩VA无码中文字幕| 精品国产女同疯狂摩擦2| 国语精品自产拍在线观看网站| 亚洲人成色99999在线观看 | 国产福利萌白酱在线观看视频| 亚洲精品乱码久久久久久不卡| 国产精品麻豆欧美日韩ww| 免费看的日韩精品黄色片| 日本亚洲中文字幕不卡| 亚洲精品美女久久7777777| 无码h黄肉动漫在线观看| 一本av高清一区二区三区| 亚洲熟女乱色综合一区| 日本深夜福利在线观看| free性开放小少妇| 我要看特黄特黄的亚洲黄片| 亚洲国产精品一区二区第一页| 久久精品国产99国产精品澳门| 国产精品一区二区在线欢| 亚洲一区二区在线av| 国产美熟女乱又伦AV果冻传媒| 色婷婷日日躁夜夜躁| 国产美女久久久亚洲综合 | 在线亚洲午夜片av大片| 中文字幕 欧美日韩| 国产v综合v亚洲欧美大天堂| 国产精品午夜福利清纯露脸| 成人国产精品日本在线观看| 国产av无码国产av毛片| 狠狠躁夜夜躁人人爽天天5| 精品国产一区av天美传媒| 波多野结衣一区二区三区高清| 青青草国产自产一区二区| 亚洲中文字幕在线二页|