|
@@ -13,63 +13,73 @@ import { UniEchartsResolver } from 'uni-echarts/resolver'
|
|
|
import { UniEcharts } from 'uni-echarts/vite'
|
|
import { UniEcharts } from 'uni-echarts/vite'
|
|
|
import UnoCSS from 'unocss/vite'
|
|
import UnoCSS from 'unocss/vite'
|
|
|
import AutoImport from 'unplugin-auto-import/vite'
|
|
import AutoImport from 'unplugin-auto-import/vite'
|
|
|
-import { defineConfig } from 'vite'
|
|
|
|
|
|
|
+import { defineConfig, loadEnv } from 'vite'
|
|
|
// https://vitejs.dev/config/
|
|
// https://vitejs.dev/config/
|
|
|
-export default defineConfig({
|
|
|
|
|
- base: './',
|
|
|
|
|
- optimizeDeps: {
|
|
|
|
|
- exclude: process.env.NODE_ENV === 'development' ? ['wot-design-uni', 'uni-echarts'] : [],
|
|
|
|
|
- },
|
|
|
|
|
- plugins: [
|
|
|
|
|
|
|
+export default defineConfig(({ mode }) => {
|
|
|
|
|
+ return {
|
|
|
|
|
+ base: './',
|
|
|
|
|
+ optimizeDeps: {
|
|
|
|
|
+ exclude: process.env.NODE_ENV === 'development' ? ['wot-design-uni', 'uni-echarts'] : [],
|
|
|
|
|
+ },
|
|
|
|
|
+ plugins: [
|
|
|
// https://github.com/uni-helper/vite-plugin-uni-manifest
|
|
// https://github.com/uni-helper/vite-plugin-uni-manifest
|
|
|
- UniHelperManifest(),
|
|
|
|
|
- // https://github.com/uni-helper/vite-plugin-uni-pages
|
|
|
|
|
- pagesJson({
|
|
|
|
|
- hooks: [hookUniPlatform], // 支持 vite-plugin-uni-platform
|
|
|
|
|
- dts: 'src/uni-pages.d.ts',
|
|
|
|
|
- exclude: ['**/components/**/*.*'],
|
|
|
|
|
- }),
|
|
|
|
|
- // https://github.com/uni-helper/vite-plugin-uni-layouts
|
|
|
|
|
- UniHelperLayouts(),
|
|
|
|
|
- // https://github.com/uni-helper/vite-plugin-uni-components
|
|
|
|
|
- UniHelperComponents({
|
|
|
|
|
- resolvers: [WotResolver(), UniEchartsResolver()],
|
|
|
|
|
- dts: 'src/components.d.ts',
|
|
|
|
|
- dirs: ['src/components', 'src/business'],
|
|
|
|
|
- directoryAsNamespace: true,
|
|
|
|
|
- }),
|
|
|
|
|
- // https://github.com/uni-ku/root
|
|
|
|
|
- UniKuRoot(),
|
|
|
|
|
- // https://uni-echarts.xiaohe.ink
|
|
|
|
|
- UniEcharts(),
|
|
|
|
|
- // https://uni-helper.cn/plugin-uni
|
|
|
|
|
- Uni(),
|
|
|
|
|
- // https://github.com/uni-ku/bundle-optimizer
|
|
|
|
|
- Optimization({
|
|
|
|
|
- enable: isMpWeixin,
|
|
|
|
|
- logger: false,
|
|
|
|
|
- }),
|
|
|
|
|
- // https://github.com/antfu/unplugin-auto-import
|
|
|
|
|
- AutoImport({
|
|
|
|
|
- imports: ['vue', '@vueuse/core', 'pinia', 'uni-app', {
|
|
|
|
|
- from: '@wot-ui/router',
|
|
|
|
|
- imports: ['createRouter', 'useRouter', 'useRoute'],
|
|
|
|
|
- }, {
|
|
|
|
|
- from: 'wot-design-uni',
|
|
|
|
|
- imports: ['useToast', 'useMessage', 'useNotify', 'CommonUtil'],
|
|
|
|
|
- }, {
|
|
|
|
|
- from: 'alova/client',
|
|
|
|
|
- imports: ['usePagination', 'useRequest'],
|
|
|
|
|
- }],
|
|
|
|
|
- dts: 'src/auto-imports.d.ts',
|
|
|
|
|
- dirs: ['src/composables', 'src/store', 'src/utils', 'src/api'],
|
|
|
|
|
- vueTemplate: true,
|
|
|
|
|
- }),
|
|
|
|
|
- // https://github.com/antfu/unocss
|
|
|
|
|
- // see unocss.config.ts for config
|
|
|
|
|
- UnoCSS(),
|
|
|
|
|
- ],
|
|
|
|
|
- server: {
|
|
|
|
|
- host: '0.0.0.0',
|
|
|
|
|
- },
|
|
|
|
|
|
|
+ UniHelperManifest(),
|
|
|
|
|
+ // https://github.com/uni-helper/vite-plugin-uni-pages
|
|
|
|
|
+ pagesJson({
|
|
|
|
|
+ hooks: [hookUniPlatform], // 支持 vite-plugin-uni-platform
|
|
|
|
|
+ dts: 'src/uni-pages.d.ts',
|
|
|
|
|
+ exclude: ['**/components/**/*.*'],
|
|
|
|
|
+ }),
|
|
|
|
|
+ // https://github.com/uni-helper/vite-plugin-uni-layouts
|
|
|
|
|
+ UniHelperLayouts(),
|
|
|
|
|
+ // https://github.com/uni-helper/vite-plugin-uni-components
|
|
|
|
|
+ UniHelperComponents({
|
|
|
|
|
+ resolvers: [WotResolver(), UniEchartsResolver()],
|
|
|
|
|
+ dts: 'src/components.d.ts',
|
|
|
|
|
+ dirs: ['src/components', 'src/business'],
|
|
|
|
|
+ directoryAsNamespace: true,
|
|
|
|
|
+ }),
|
|
|
|
|
+ // https://github.com/uni-ku/root
|
|
|
|
|
+ UniKuRoot(),
|
|
|
|
|
+ // https://uni-echarts.xiaohe.ink
|
|
|
|
|
+ UniEcharts(),
|
|
|
|
|
+ // https://uni-helper.cn/plugin-uni
|
|
|
|
|
+ Uni(),
|
|
|
|
|
+ // https://github.com/uni-ku/bundle-optimizer
|
|
|
|
|
+ Optimization({
|
|
|
|
|
+ enable: isMpWeixin,
|
|
|
|
|
+ logger: false,
|
|
|
|
|
+ }),
|
|
|
|
|
+ // https://github.com/antfu/unplugin-auto-import
|
|
|
|
|
+ AutoImport({
|
|
|
|
|
+ imports: ['vue', '@vueuse/core', 'pinia', 'uni-app', {
|
|
|
|
|
+ from: '@wot-ui/router',
|
|
|
|
|
+ imports: ['createRouter', 'useRouter', 'useRoute'],
|
|
|
|
|
+ }, {
|
|
|
|
|
+ from: 'wot-design-uni',
|
|
|
|
|
+ imports: ['useToast', 'useMessage', 'useNotify', 'CommonUtil'],
|
|
|
|
|
+ }, {
|
|
|
|
|
+ from: 'alova/client',
|
|
|
|
|
+ imports: ['usePagination', 'useRequest'],
|
|
|
|
|
+ }],
|
|
|
|
|
+ dts: 'src/auto-imports.d.ts',
|
|
|
|
|
+ dirs: ['src/composables', 'src/store', 'src/utils', 'src/api'],
|
|
|
|
|
+ vueTemplate: true,
|
|
|
|
|
+ }),
|
|
|
|
|
+ // https://github.com/antfu/unocss
|
|
|
|
|
+ // see unocss.config.ts for config
|
|
|
|
|
+ UnoCSS(),
|
|
|
|
|
+ ],
|
|
|
|
|
+ server: {
|
|
|
|
|
+ host: '0.0.0.0',
|
|
|
|
|
+ port: 8181,
|
|
|
|
|
+ proxy: {
|
|
|
|
|
+ '/api': {
|
|
|
|
|
+ target: loadEnv(mode, process.cwd()),
|
|
|
|
|
+ changeOrigin: true,
|
|
|
|
|
+ rewrite: path => path.replace(/^\/api/, ''),
|
|
|
|
|
+ },
|
|
|
|
|
+ },
|
|
|
|
|
+ },
|
|
|
|
|
+ }
|
|
|
})
|
|
})
|