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
What is the purpose of creating your own website u...
Preface In LINUX, periodic tasks are usually hand...
1. Download MySQL Workbench Workbench is a graphi...
This article shares with you the MySQL 8.0.13 ins...
introduce You Yuxi’s original words. vite is simi...
This article shares the specific code of JavaScri...
I won’t talk about the use of SSL certificates. F...
1. Multiple calls to single arrow Once a single a...
HTML img tag: defines an image to be introduced in...
As shown in the figure: Check port usage: sudo ne...
Prometheus (also called Prometheus) official webs...
1. Who is tomcat? 2. What can tomcat do? Tomcat i...
1. Create a test table CREATE TABLE `testsign` ( ...
As a software developer, you must have a complete...
Table of contents Preface 1. GMT What is GMT Hist...