首页 > 其他分享 >vite.config.ts配置文件

vite.config.ts配置文件

时间:2023-05-06 19:22:31浏览次数:34  
标签:src vue 配置文件 less ts import config vite

import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import { resolve } from 'path'

import vueSetupExtend from 'vite-plugin-vue-setup-extend'
import AutoImportt from 'unplugin-auto-import/vite'
import Components from 'unplugin-vue-components/vite'
import { VantResolver } from 'unplugin-vue-components/resolvers'
import pxToViewport from 'postcss-px-to-viewport'

export default defineConfig({
  // 启动后自动打开网页
  server: { open: true },
  // 设置src别名@,还需要在tsconfig.ts中配置baseUrl和paths
  resolve: {
    alias: {
      '@': resolve(__dirname, './src')
    }
  },
  plugins: [
    vue(),
    // vue文件的script标签添加name属性,用来设置组件名称
    vueSetupExtend(),
    AutoImportt({
      // 自动导入组合API和vueuse的hooks
      imports: ['vue', 'vue-router', 'pinia', '@vueuse/core'],
      // 自动导入Vant组件
      resolvers: [VantResolver()],
      dts: './src/auto-import.d.ts'
    }),
    Components({
      // 按需引入Vant组件
      resolvers: [VantResolver()],
      dts: './src/vant-components.d.ts'
    })
  ],
  css: {
    postcss: {
      plugins: [
        // 将px转换为viewport
        pxToViewport({
          unitToConvert: 'px',
          viewportWidth: 375
        })
      ]
    },
    // 引入全局less变量、函数
    preprocessorOptions: {
      less: {
        modifyVars: {
          hack: `true; @import (reference) '${resolve(__dirname, 'src/assets/less/index.less')}';`
        },
        javascriptEnabled: true
      }
    }
  }
})

标签:src,vue,配置文件,less,ts,import,config,vite
From: https://www.cnblogs.com/gyxc/p/17378300.html

相关文章

  • spring和hibernate配置文件整合
    为了操作方便,我们经常在spring整合hibernate的WEB项目中省去了用hibernate.cfg.xml的麻烦,将hibernate的信息直接配置在Spring配置文件中下面的都是针对Spring整合Hibernate(注解方式的hibernate)来说的hibernate.cfg.xml和applicationContext.xml原始配置......
  • Axure调用echarts图表
    本文分为两个模块:代码修改、代码引用代码修改 代码修改,需要一个固定模板,然后将echarts源码复制放在模板中即可;以下是模板代码代码模板:模板开始javascript:varscript=document.createElement('script');script.type="text/javascript";script.src="https://cdn.jsdeli......
  • java filter过滤器 读取配置文件properties的值
    http://www.yayihouse.com/yayishuwu/chapter/29811.获取application.properties的值如userId=1 2.一般实体中采用@Value既可获取@Value("userIdl")privateStringuserId; 但是在filter中,需要用上下文对象来获取filter的生命周期如下:web应用程序启动时,web服务器将创......
  • ASEMI代理亚德诺LTC2954CTS8-2#TRMPBF车规级芯片
    编辑-ZLTC2954CTS8-2#TRMPBF参数描述:型号:LTC2954CTS8-2#TRMPBF电源电压范围:2.7-26.4VVIN供电电流:6-12µAVIN欠电压锁定:2.2-2.5VVIN欠压锁定滞后:50-700mVONT上拉电流:–2.4to–3.6µAONT下拉电流:2.4-3.6µA内部开启解除抖动时间:26-41ms额外的可调节开启时间:9-13.5m......
  • kubernets学习
    引用:......
  • 使用Swagger Codegen生成TS相关代码
    官方介绍地址:https://github.com/swagger-api/swagger-codegen1.安装JDK【略】2.下载jar包wgethttps://repo1.maven.org/maven2/io/swagger/codegen/v3/swagger-codegen-cli/3.0.41/swagger-codegen-cli-3.0.41.jar-Oswagger-codegen-cli.jar或Invoke-WebRequest-OutFil......
  • win11 C盘的配置文件无法编辑 一个命令就好
    在配置win11的服务时,不小时安装在了C盘。而win11对C盘的文件编辑有严格限制。你要注册在线账户设为管理员才能编辑。除了这种方法,还怎么编辑呢?简单的哩,cmd以管理员身份运行。这个会吧。然后在cmd里进到你需要编辑的目录,如下面我要弄这个。mongoDB的配置文件,在命令下使用notepa......
  • Uncaught TypeError: f.__fbeventsModules[a] is not a function at f.__fbeventsM
    UncaughtTypeError:f.__fbeventsModules[a]isnotafunctionatf.__fbeventsModules.f.getFbeventsModules怎么了这个错误通常是因为代码中使用了Facebook的跟踪代码,但是在加载该代码之前,代码中尝试访问跟踪模块。这个错误有几种可能的原因:Facebook跟踪代码没有正......
  • OpenTSDB 安装
     下载目录https://github.com/OpenTSDB/opentsdb/releaseshttps://github.com/OpenTSDB/opentsdb/releases/download/v2.4.0/opentsdb-2.4.0.noarch.rpm安装GnuPlotyuminstallgnuplot-y直接安装OpenTSDB会报错[root@ecs-t-001-0001openTSDB]#rpm-ivhopentsdb-2.4.0.noarc......
  • 常见的配置文件
    常用的配置文件内容目录常用的配置文件内容日志配置CSRF_TOKEN跨站请求伪造日志配置importloggingimportlogging.configstandard_format='[%(asctime)s][%(threadName)s:%(thread)d][task_id:%(name)s][%(filename)s:%(lineno)d]'\'[%(levelname)s]......