关于vue3.0 + vite + ts 打包的坑

关于vue3.0 + vite + ts 打包的坑
我的项目是用vue3.0.x+ vite2.4.x + ts 4.3.x版本开发的,引入一些elementui,axios,vuex等插件,用npm run build 打包的时候报了一大堆错,后来发现原来是vue-tsc --noEmit && vite build的问题

报错详情:

关于vue3.0 + vite + ts 打包的坑_第1张图片

 package.json文件默认配置如下:

"scripts": {
    "dev": "vite --host",
    "build:prod": "vite build --mode production",
    "serve": "vite preview",
    "lint": "eslint src/**/*.{ts,js,vue} --fix",
    "prepare": "husky install",
    "prettier": "prettier --write ."
  }

改成如下配置:"build:prod": "vite build"

"scripts": {
    "dev": "vite serve --mode development",
    "build:prod": "vite build",
    "prepare": "husky install",
    "lint:eslint": "eslint  --fix --ext .ts,.js,.vue ./src ",
    "lint:prettier": "prettier --write \"**/*.{js,cjs,ts,json,tsx,css,less,scss,vue,html,md}\"",
    "lint:stylelint": "stylelint  \"**/*.{css,scss,vue}\" --fix",
    "lint:lint-staged": "lint-staged",
    "commit": "git-cz"
  }

你可能感兴趣的:(vite,VUE3,vue.js,javascript,前端)