Allen's blog Allen's blog
首页
面经
算法 (opens new window)
分类

Allen

前端CV工程师
首页
面经
算法 (opens new window)
分类
  • Javascript

  • TypeScript

  • CSS

  • Vue

  • React

  • 框架和构建工具

    • rollup使用配置文件rollup.config.ts打包
    • webpack学习笔记
    • vite学习笔记
    • PostCSS学习笔记
    • nuxt3项目搭建与配置
    • ts、vite、vitepress配置别名alias
      • vite 别名
      • ts 别名
      • vitepress 别名
  • 工具库

  • 常见业务场景

  • Bug

  • 项目实战

  • 前端
  • 框架和构建工具
Allen
2023-08-17
目录

ts、vite、vitepress配置别名alias

# vite 别名

// vite.config.js

import path from 'path'
import { defineConfig } from 'vite'

// https://vitejs.dev/config/
export default defineConfig({
    resolve: {
        alias: {
            '@hooks': path.resolve(__dirname, './src/_hooks')
        }
    }
})
1
2
3
4
5
6
7
8
9
10
11
12
13

# ts 别名

// tsconfig.json

{
    "compilerOptions": {
        "paths": {
            "@hooks/*": ["./src/_hooks/*"]
        }
    }
}
1
2
3
4
5
6
7
8
9

# vitepress 别名

// .vitepress/config.ts

import { defineConfig } from 'vitepress'

// https://vitepress.dev/reference/site-config
export default defineConfig({
    vite: {
        resolve: {
            alias: {
                '@hooks': path.resolve(__dirname, '../src/_hooks')
            }
            // {
            //   find: /^.*\/VPDemo\.vue$/,
            //   replacement: fileURLToPath(
            //     new URL('./theme/MobileDemo.vue', import.meta.url)
            //   ),
            // },
        }
    }
})
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
上次更新: 2023/12/16, 09:22:46
nuxt3项目搭建与配置
Dayjs使用笔记

← nuxt3项目搭建与配置 Dayjs使用笔记→

最近更新
01
rollup使用配置文件rollup.config.ts打包
12-08
02
package.json导出类型
12-08
03
关键问题方案
11-17
更多文章>
Theme by Vdoing | Copyright © 2023-2023 Allen | Github
  • 跟随系统
  • 浅色模式
  • 深色模式
  • 阅读模式