Projando Vue 3++ +タイススクリプト+エスリント+テールウインド


NOSにおけるLTimosメゾン・テンホーVue COMU MEUフレームワークプリンシパルデTrabalho、E mais Recentemente Comecei a migraは、2つのパラオo Vue 3をします.パラiniciar meus projetos com vueVite , UMA Ferramenta de desenvolvimento無料、ISSOの意味NA PRのエヌティカティカn n o o ocorre広報-ビルドem desenvolvimeno、oferecendo aoサーバos mのDulos JavaScript Nativos.vantagens de se zizzar o vite est o o no no ganho na speidade de cria poso o o eホットモジュール置換として.
ニストGuiia Irei Mostrar como fa - o - Parallar Mus Projetos , E al ' m m Das Ferramentas t t Tune , Tulo , Iri incluir Tamb - mPrettier , HuskyTailwind . Nicica , Muito Menos , Foras mais correta , Apenas a a a a a a a a a a a a a a a a a a a a a a fa Minhas Configilura - Ses . es .エスパーqueエッセGuiaテアジュド.

INIPLANE A PLAYO O COM COM
アッラoターミナルnaパスタエムque deseja criar o projeto e digite o comando abaixo.Lembrando que apは、sです@vitejs/app e onde vocは、eseshe o nomeにseu projetoをします.
#NPM
  npm init @vitejs/app my-project

#YARN
  yarn create @vitejs/app my-project
AOロダールoコマンドアカンマの端末は、podemos会議のo o Viteのnosダオオペアンプ
? Select a template: …
▸ vanilla
  vue
  vue-ts
  react
  react-ts
  preact
  preact-ts
  lit-element
  lit-element-ts
como podemos ver,o vite uma uma ferramenta que independde doフレームワークパラオノッソカロVamosエスコラvue-ts .
アオSelecionarは、Op Method - o O、rapidamente o nosso projetoによって、クリドです.アゴラNavegamosパラシュートで降下する人Dontro daパスタは、NCIASに依存して、projeto e instalamosをします.
  cd my-project
#NPM
  npm install 
  npm run dev 

#YARN
  yarn
  yarn dev
プロントは、proproto por padrは、o est est roodando na porta 3000
Projeto criadoセグエのseguinte estruturaデpastas.
├── node_modules
├── package-lock.json
├── package.json
├── public
│   └── favicon.ico
├── src
│   ├── App.vue
│   ├── assets
│   │   └── logo.png
│   ├── components
│   │   └── HelloWorld.vue
│   └── main.ts
├── tsconfig.json
└── vite.config.ts
se vocは、利用可能なvvcode、pode seguir os passos abaixoです.
  • アブラsrc/main.ts
  • ABRA O入力DE Comando(Ctrl + Shift + P)は、Vscodeをします
  • procure e - rode "Select Typescript Version "->"Workspace Versionを使う

  • コンフィギュレーション
    VUE 3 POR padrについてmain.ts . <研究ノート>ファシリティー・ファイザーe adnonar na tag<script> ドスアーキヴォス.vue oパラメータlang="ts" e pron、nosso projeto jは、entendeタイプスクリプトです.
    いいえArquivotsconfig.json ポモインテ・ファザーの詩学
    {
      "compilerOptions": {
        "target": "esnext",
        "module": "esnext",
        "importHelpers": true,
        "skipLibCheck": true,
        "esModuleInterop": true,
        "allowSyntheticDefaultImports": true,
        "moduleResolution": "node",
        "isolatedModules": true,
        "strict": true,
        "jsx": "preserve",
        "sourceMap": true,
        "baseUrl": ".",
        "lib": ["esnext", "dom",
          "dom.iterable",
          "scripthost"],
        "types": ["vite/client"],
        "plugins": [{ "name": "@vuedx/typescript-plugin-vue" }]
      },
      "include": ["src/**/*.ts", "src/**/*.d.ts", "src/**/*.tsx", "src/**/*.vue"],
      "exclude": [
        "node_modules"
      ]
    }
    

    エスライン
    #NPM
    npm i -D eslint eslint-plugin-vue @vue/eslint-config-typescript @typescript-eslint/parser @typescript-eslint/eslint-plugin typescript
    
    #YARN
    yarn add -D eslint eslint-plugin-vue @vue/eslint-config-typescript @typescript-eslint/parser @typescript-eslint/eslint-plugin typescript
    
    APは、Instalaを非難します.エスライントラック.JSON Na RizはSegintesとしてProjeto e Inserirをします.
    {
      "root": true,
      "env": {
        "browser": true,
        "es2021": true,
        "node": true
      },
      "extends": [
        "plugin:vue/vue3-recommended",
        "eslint:recommended",
        "@vue/typescript/recommended"
      ],
      "parserOptions": {
        "ecmaVersion": 2021
      },
      "plugins": [],
      "rules": {}
    }
    
    RengrasデSuaとしてのNesse Arquivo vocは、pode adicionar OSプラグインeをします.
    Podemos adicionar o seguinteスクリプトao nossopackage.json
    "scripts": {
      "lint:script": "eslint --ext .ts,vue --ignore-path .gitignore ."
    }
    
    アッシムpodemosロダールOスクリプトCOMフラグ--fix Parcorre o o dos dos Arquivosは、projetoをします.エサ・コーレの原典についての一考察

    前途
    Adicionamos oは、質素な形式のnosso projetoをきれいにします.
    #NPM
    npm i -D prettier eslint-plugin-prettier @vue/eslint-config-prettier
    
    #YARN
    yarn add -D prettier eslint-plugin-prettier @vue/eslint-config-prettier
    
    依存するNCIAS、Criamos um ArquivoとしてのAO Instalar.prettierrc seguintesコンフィギュレーションとしてのE挿入形.リグda suaとしてのAqui Vocは、Pode Adiocionarを認めます.
    {
      "singleQuote": true,
      "semi": false,
      "vueIndentScriptAndStyle": true
    }
    
    いいえArquivo.eslintrc.json デビルズAdas onis onis onis onisは、es esのEvitar regras duplicadas que
    {
      "extends": [
        "plugin:vue/vue3-recommended",
        "eslint:recommended",
        "@vue/typescript/recommended",
        "prettier",
        "prettier/vue",
      ]
    }
    

    ハスキー
    HukyパラRealizarを利用してください.Aquiのvamosコンフィギュレーションapenas oリンティング.
    #NPM
    npm i -D husky lint-staged
    
    #YARN
    yarn add -D husky lint-staged
    
    アドリノモスpackage.json
    {
      "husky": {
        "hooks": {
          "pre-commit": "lint-staged"
        }
      },
      "lint-staged": {
        "*.{ts,vue}": "eslint --fix"
      }
    }
    

    風車
    Tuwind風MMA選択肢フレームワークCSS
    #NPM
    npm install -D tailwindcss@latest postcss@latest autoprefixer@latest
    
    #YARN
    yarn add -D tailwindcss@latest postcss@latest autoprefixer@latest
    
    エムセゲアiniciamos o尾風rodando o comando abaixo.シュラアウドアルアリオtailwind.config.js エムアルキヴォーpostcss.config.jsいいえArquivotailwind.config.js ポドモススコンフィギュレーションpurge パラO風風除けリムーバーのOSを使用してください.
      module.exports = {
       purge: [],
       purge: ['./index.html', './src/**/*.{vue,js,ts,jsx,tsx}'],
        darkMode: false, // or 'media' or 'class'
        theme: {
          extend: {},
        },
        variants: {
          extend: {},
        },
        plugins: [],
      }
    

    アオザイのCSS
    デロンダノッサパスタsrc CriamosアムArquivoindex.css , Nele adicionamos o Tuwind da sguinte maneira
    @tailwind base;
    @tailwind components;
    @tailwind utilities;
    
    アゴラノArquivomain.ts Premiisos Inserar ESSE CSS E PROON , NOSSO TARWARES EST DOM ADADIONADO ao nosso projeto
    import { createApp } from 'vue'
    import App from './App.vue'
    import './index.css'
    
    createApp(App).mount('#app')
    
    SEの見積もりcom o projeto rodando、pare e rode novamente.AO - ViteとしてのGrA
    Voc - Podeについてaqui

    追加:編集
    エディトリアルコンフィギュレーションについてESGAUUNS ESSE ARKIVO LEE LUDIO Autoticamente E APLICAをConfigurasとして理想的なエムcasos onre eximaのumaのdesdesvolvimene e se deseja que todos estejam com a mesma config ila o o no no editor de texto ou ide de suaは,ncnを好む.EditorConfig - voc - de - de - de - de - alquio - Esse - Forato - Arquivoを使用してください.
    クリエアムArquivo.regrasデsuaとしてのeditorconfig e adicioneは、NCIAを好む.アルArquivo最終的なdeve ser algo parecido com A Configuraは、Sponse o o Aaixoをします.
    root = true
    
    [*]
    end_of_line = lf
    indent_style = space
    indent_size = 2
    charset = utf-8
    trim_trailing_whitespace = true
    insert_final_newline = true
    

    結論
    クリラの詩は、o oのprojeto vueを利用して、Useの選択肢Vaas cli、que Utiliza oウェブパックcomoバンドル.Optando Pelo USOは、Vann NのもののGanhamosパフォーマンスdurante o desenvolvimento、MAS abrimos m - no o Da Configura So - es que que o vue cli j j faz para n n ' s s、como a integraの傷を得ます.第二のモメントEUにおいては、コンソーシアムにおいて、コンフィギュレーションにおいては、上記のように設定されている.Arireto que Boa Parte Das Projeto Livezam Pelo Menos Algumas Desasは、Configilaを含みます、e Coco Necessは、リオ、seguindo a l gisのgica deste guia、suc prとしてのvocは、pode incluirです.
    レベルブラット・エックス・エス・アスのコンフィギュレーションとしてのEU重要な点vocは、conhecer o seu projeto e com oテンポエンエンダーQuais Configilaがそうであるということです.<論文>ギニア・コムにおける謝罪とその周辺OUTRA pONEは、Thernologia Evoliエムum TurnologiaエグゼクティブEm - um - Le - Mortelado、Entのために、Intetante TerエムMente queをConfiguras Les . es PODEM TRIMER COM O Passar Doテンポとして扱います.