Because we are using Vite Ts to develop the Vue3 component library, we need to install typescript and vue3. At the same time, the project will use Less to manage the component library style
1 |
|
Use pnpm if you want to install it at the project root directory, you need to add -w
Execute npx tsc --init
in the root directory, and then ts will be automatically generated The configuration file tsconfig.json
, and then we will make a replacement
1 2 3 4 5 6 7 8 9 10 11 12 13 |
|
tsconfig.json
We will make such a configuration for the time being, and there may be certain adjustments in the future.
Because what we want to develop is a Vue3 component library, we definitely need a Vue3 project to test our component library, so here we will build a vue3 project based on Vite Vue3 project to debug components. Therefore, we create a new folder called play in the root directory and initialize pnpm init
. Subsequent component debugging will be carried out under this project. Next we will start building a Vue3 Vite project
We need to installvite
andvitejs/plugin-vue
plug-ins,@vitejs/plugin-vue
The plug-in is for parsing files with the suffix .vue
. Execute
1 |
|
Newvite.config.ts
Configuration file
1 2 3 4 5 6 |
|
##@vitejs/plugin-vuewill load the index.html under play by default
1 2 3 4 5 6 7 8 9 10 11 12 13 |
|
script tag Need to add
type="module"
app.vuefile
1 2 3 |
|
main.ts
1 2 3 4 5 6 |
|
package.jsonConfiguration
scriptsScript
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
|
pnpm-workspace.yaml file
1 2 3 |
|
pnpm run dev, we can start our play project
##But there is a problem that ts cannot recognize the
file, so the compiler will report red
At this time we need to create a new declaration file
to let ts know the file *.vue
1 2 3 4 |
|
Copy after login
The error message disappears at this time. The above is the detailed content of How to configure the environment of Vue3 component library. For more information, please follow other related articles on the PHP Chinese website!
Related labels:
Previous article:How to use mockjs to randomly simulate data in Vue3+Vite project
Next article:How to use hooks in Vue3 projects
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
-
2025-02-26 03:58:14
-
2025-02-26 03:38:10
-
2025-02-26 03:17:10
-
2025-02-26 02:49:09
-
2025-02-26 01:08:13
-
2025-02-26 00:46:10
-
2025-02-25 23:42:08
-
2025-02-25 22:50:13
-
2025-02-25 21:54:11
-
2025-02-25 20:45:11
Latest Issues
Vue2 to Vue3 migration - How to update mixins added in Vue2 components in Vue3's setup API.
From 1970-01-01 08:00:00
0
0
0
How to use Vue3 + TypeScript v-model on text field? "Error: Invalid allocation target"
From 1970-01-01 08:00:00
0
0
0
Related Topics
More>
Popular Recommendations
Popular Tutorials
More>
-
-
-
JAVA Beginner's Video Tutorial
2653386
-
-
Latest Downloads
More>
-
-
-
-
-
-
-
-