introduceYou Yuxi’s original words.
createExecute npm init @vitejs/app, I choose vue-ts here Version"vite": "^2.0.0-beta.48" alias vite.config.ts const path = require('path') alias: { "@": path.resolve(__dirname, "src"), "@c": path.resolve(__dirname, "src/components") }, Environment variable configuration 1. Create in the root directory 2. Only variables prefixed with VITE_ are exposed to the code processed by Vite. The following is the .env.production file, and the others are similar. 3. Start the package.json file and add --mode test after the command. This is the same as vue2 "dev:test": "vite --mode test", 4. Usage is somewhat different from vue2. It cannot be read in vite.config.ts, but other files can be obtained import.meta.env The output is: Add vue-router (vue3 uses version 4.0+) 1. Installation npm i [email protected] --save, install version 4.0 2. index.ts import {createRouter, createWebHashHistory, RouteRecordRaw} from 'vue-router' // @ts-ignore const test = () => import('../views/test1.vue') const routes: Array<RouteRecordRaw> = [ {path: "/", redirect: "/test1"}, { path: "/test1", name: 'test1', component: test, } ] const router = createRouter({ history: createWebHashHistory(), routes: routes }) export default router 3. main.ts import router from "./router" createApp(App) .use(router) .mount('#app') Add vuex (version 4 or above) 1. Installation npm i vuex@index -D 2. store/index.ts import { createStore } from 'vuex' export default createStore({ state: { }, //... }) 3. main.ts import store from './store' createApp(App) .use(store) .mount('#app') scss environment 1. Install npm i sass -D, you can use sass syntax directly css: { preprocessorOptions: { scss: { additionalData: `@import "./src/assets/scss/global.scss";` //your scss file path} } }, This is the end of this article about detailed explanation of vite2.0 configuration learning (typescript version). For more relevant vite2.0 configuration content, please search 123WORDPRESS.COM's previous articles or continue to browse the following related articles. I hope everyone will support 123WORDPRESS.COM in the future! You may also be interested in:
|
<<: Detailed explanation of mktemp, a basic Linux command
>>: Detailed explanation of MySQL limit usage and performance analysis of paging query statements
Table of contents Preface: 1. Reasons for the eve...
Table of contents 1. Introduction to priority que...
Table of contents Scenario Analysis Development S...
system: VMTOOLs Download: Link: https://pan.baidu...
How to solve the problem of 1045 when the local d...
1. Use the <a> tag to complete <a href=&...
This article shares the specific code of JavaScri...
1. Use Docker Compose to configure startup If you...
In the previous article, we introduced the detail...
If I want to make the form non-input-capable, I se...
nohup Command When using Unix/Linux, we usually w...
As shown below: nsenter -t 1 -m -u -n -i sh -c &q...
Table of contents Dirty pages (memory pages) Why ...
Table of contents Problems with resource manageme...
Table of contents 1. CDN introduction 1.1 react (...