vite.config.ts 742 B

12345678910111213141516171819
  1. import { defineConfig } from 'vite'
  2. import uni from '@dcloudio/vite-plugin-uni'
  3. // https://vitejs.dev/config/
  4. export default defineConfig({
  5. build: {
  6. // 开发阶段启用源码映射:https://uniapp.dcloud.net.cn/tutorial/migration-to-vue3.html#需主动开启-sourcemap
  7. sourcemap: process.env.NODE_ENV === 'development',
  8. },
  9. plugins: [uni(), { // 自定义插件禁用vite:vue插件的devToolsEnabled,强制编译 vue 模板时 inline 为 true
  10. name: 'fix-vite-plugin-vue',
  11. configResolved(config) {
  12. const plugin = config.plugins.find((p) => p.name === 'vite:vue')
  13. if (plugin && plugin.api && plugin.api.options) {
  14. plugin.api.options.devToolsEnabled = false
  15. }
  16. },
  17. }],
  18. })