vue基础配置

vite.config.ts

import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import path from "path";
//引入svg需要用到的插件
import { createSvgIconsPlugin } from 'vite-plugin-svg-icons'
//mock插件提供方法
import { viteMockServe } from 'vite-plugin-mock'
export default defineConfig(({ command }) => {
  return {
    plugins: [vue(),
      createSvgIconsPlugin({
        iconDirs: [path.resolve(process.cwd(), 'src/assets/icons')],
        symbolId: 'icon-[dir]-[name]'
      }),
      viteMockServe({
        localEnabled: command === 'serve',
      })
    ],
    resolve: {
      alias: {
        "@": path.resolve(__dirname, "./src"),
      }
    },
    css: { //scss全局变量的配置
      preprocessorOptions: {
        scss: {
          javascriptEnabled: true,
          additionalData: `@import "./src/styles/variable.scss";`
        }
      }
    },
  }
})

tsconfig.json

{
  "compilerOptions": {
    "target": "ES2020",
    "useDefineForClassFields": true,
    "module": "ESNext",
    "lib": ["ES2020", "DOM", "DOM.Iterable"],
    "skipLibCheck": true,

    /* Bundler mode */
    "moduleResolution": "bundler",
    "allowImportingTsExtensions": true,
    "resolveJsonModule": true,
    "isolatedModules": true,
    "noEmit": true,
    "jsx": "preserve",

    /* Linting */
    "strict": true,
    "noUnusedLocals": true,
    "noUnusedParameters": true,
    "noFallthroughCasesInSwitch": true,
    "baseUrl":"./",    //解析非相对模块的基地址,默认是当前目录
    "paths":{    //路径映射,相对于baseUrl
      "@/*" :["./src/*"]
    }
  },
  "include": ["src/**/*.ts", "src/**/*.tsx", "src/**/*.vue"],
  "references": [{ "path": "./tsconfig.node.json" }]
}

package.json

{
  "name": "cdn",
  "private": true,
  "version": "0.0.0",
  "type": "module",
  "scripts": {
    "dev": "vite",
    "build": "vue-tsc && vite build",
    "build:test": "vue-tsc && vite build --mode test",
    "build:pro": "vue-tsc && vite build --mode production",
    "preview": "vite preview"
  },
  "dependencies": {
    "@element-plus/icons-vue": "^2.3.1",
    "axios": "^1.6.8",
    "element-plus": "^2.7.2",
    "pinia": "^2.1.7",
    "sass": "^1.75.0",
    "vue": "^3.4.21",
    "vue-router": "^4.3.2"
  },
  "devDependencies": {
    "@types/node": "^20.12.7",
    "@vitejs/plugin-vue": "^5.0.4",
    "fast-glob": "^3.3.2",
    "mock.js": "^0.2.0",
    "typescript": "^5.2.2",
    "vite": "^5.2.0",
    "vite-plugin-mock": "2.9.6",
    "vite-plugin-svg-icons": "^2.0.1",
    "vue-tsc": "^2.0.6"
  }
}

main.ts

import { createApp } from 'vue'
import App from './App.vue'
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
//@ts-ignore 
import zhCn from 'element-plus/es/locale/lang/zh-cn.mjs'
import 'virtual:svg-icons-register'
import globalComponent from '@/components'
import '@/styles/index.scss'
import router from '@/router'
import pinia from './store'
createApp(App).use(ElementPlus,{ locale: zhCn }).use(globalComponent).use(router).use(pinia).mount('#app')

reset.scss

/* http://meyerweb.com/eric/tools/css/reset/
   v5.0.1 | 20191019
   License: none (public domain)
*/

html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
b, u, i, center,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td,
article, aside, canvas, details, embed,
figure, figcaption, footer, header, hgroup,
main, menu, nav, output, ruby, section, summary,
time, mark, audio, video {
	margin: 0;
	padding: 0;
	border: 0;
	font-size: 100%;
	font: inherit;
	vertical-align: baseline;
}
/* HTML5 display-role reset for older browsers */
article, aside, details, figcaption, figure,
footer, header, hgroup, main, menu, nav, section {
	display: block;
}
/* HTML5 hidden-attribute fix for newer browsers */
*[hidden] {
    display: none;
}
body {
	line-height: 1;
}
menu, ol, ul {
	list-style: none;
}
blockquote, q {
	quotes: none;
}
blockquote:before, blockquote:after,
q:before, q:after {
	content: '';
	content: none;
}
table {
	border-collapse: collapse;
	border-spacing: 0;
}

相关推荐

  1. vue基础配置

    2024-05-14 03:16:06       34 阅读
  2. vue3配置基础路径

    2024-05-14 03:16:06       32 阅读
  3. vue 基础

    2024-05-14 03:16:06       48 阅读
  4. <span style='color:red;'>Vue</span><span style='color:red;'>基础</span>

    Vue基础

    2024-05-14 03:16:06      51 阅读
  5. vue基础

    2024-05-14 03:16:06       58 阅读
  6. <span style='color:red;'>VUE</span><span style='color:red;'>基础</span>

    VUE基础

    2024-05-14 03:16:06      38 阅读
  7. <span style='color:red;'>vue</span><span style='color:red;'>基础</span>

    vue基础

    2024-05-14 03:16:06      33 阅读
  8. <span style='color:red;'>Vue</span><span style='color:red;'>基础</span>

    Vue基础

    2024-05-14 03:16:06      27 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-05-14 03:16:06       98 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-05-14 03:16:06       106 阅读
  3. 在Django里面运行非项目文件

    2024-05-14 03:16:06       87 阅读
  4. Python语言-面向对象

    2024-05-14 03:16:06       96 阅读

热门阅读

  1. picoCTF-Web Exploitation-Web Gauntlet

    2024-05-14 03:16:06       39 阅读
  2. vue3中实现地区下拉选择组件封装

    2024-05-14 03:16:06       29 阅读
  3. PHP数据库

    2024-05-14 03:16:06       24 阅读
  4. Redis中,hash的使用

    2024-05-14 03:16:06       33 阅读
  5. 算法学习笔记(匈牙利算法)

    2024-05-14 03:16:06       40 阅读
  6. LabVIEW电机测试系统

    2024-05-14 03:16:06       38 阅读
  7. mysql的导入与导出

    2024-05-14 03:16:06       27 阅读
  8. google hack常用命令举例

    2024-05-14 03:16:06       36 阅读