vite.config.ts 1.5 KB
Newer Older
fxy060608's avatar
fxy060608 已提交
1 2 3 4
import path from 'path'
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import vueJsx from '@vitejs/plugin-vue-jsx'
fxy060608's avatar
fxy060608 已提交
5
import { isAppNVueNativeTag } from '@dcloudio/uni-shared'
fxy060608's avatar
fxy060608 已提交
6 7 8 9 10

function resolve(file: string) {
  return path.resolve(__dirname, file)
}

fxy060608's avatar
fxy060608 已提交
11 12
export default defineConfig({
  root: __dirname,
fxy060608's avatar
fxy060608 已提交
13 14
  define: {
    global: 'window',
fxy060608's avatar
fxy060608 已提交
15
    __PLATFORM__: "'app'",
16
    __DEV__: `(process.env.NODE_ENV !== 'production')`,
fxy060608's avatar
fxy060608 已提交
17 18 19 20 21 22 23 24 25 26 27
    __NODE_JS__: false,
    __APP_VIEW__: false,
    __VUE_OPTIONS_API__: true,
    __VUE_PROD_DEVTOOLS__: false,
    __UNI_FEATURE_WX__: true,
    __UNI_FEATURE_PROMISE__: false,
    __UNI_FEATURE_I18N_EN__: true,
    __UNI_FEATURE_I18N_ES__: true,
    __UNI_FEATURE_I18N_FR__: true,
    __UNI_FEATURE_I18N_ZH_HANS__: true,
    __UNI_FEATURE_I18N_ZH_HANT__: true,
fxy060608's avatar
fxy060608 已提交
28
  },
fxy060608's avatar
fxy060608 已提交
29 30 31 32 33 34 35 36
  resolve: {
    alias: [
      {
        find: '@dcloudio/uni-core',
        replacement: resolve('../uni-core/src'),
      },
    ],
  },
fxy060608's avatar
fxy060608 已提交
37 38 39 40
  build: {
    minify: false,
    lib: {
      name: 'components',
fxy060608's avatar
fxy060608 已提交
41
      entry: path.resolve(__dirname, 'src/nvue/components.ts'),
fxy060608's avatar
fxy060608 已提交
42
      formats: ['es'],
fxy060608's avatar
fxy060608 已提交
43 44
    },
    rollupOptions: {
fxy060608's avatar
fxy060608 已提交
45
      external: ['uni', 'vue', 'weex', '@vue/shared', '@dcloudio/uni-shared'],
fxy060608's avatar
fxy060608 已提交
46 47 48 49 50
      output: {
        entryFileNames: 'components.js',
      },
    },
  },
fxy060608's avatar
fxy060608 已提交
51 52 53 54 55 56 57 58 59 60 61
  plugins: [
    vue(),
    vueJsx({
      isCustomElement: (tag) => {
        if (tag === 'slider') {
          return true
        }
        return isAppNVueNativeTag(tag)
      },
    }),
  ],
fxy060608's avatar
fxy060608 已提交
62
})