build.ts 972 字节
Newer Older
fxy060608's avatar
fxy060608 已提交
1 2 3 4 5 6
import path from 'path'
import slash from 'slash'
import { UserConfig } from 'vite'

import { resolveMainPathOnce } from '@dcloudio/uni-cli-shared'

7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
export function buildOptions(): UserConfig['build'] {
  return {
    rollupOptions: {
      input: resolveMainPathOnce(process.env.UNI_INPUT_DIR),
      external: ['vue'],
      output: {
        name: 'AppService',
        format: process.env.UNI_APP_CODE_SPLITING ? 'amd' : 'iife',
        entryFileNames: 'app-service.js',
        manualChunks: {},
        chunkFileNames(chunk) {
          if (chunk.isDynamicEntry && chunk.facadeModuleId) {
            const filepath = path.relative(
              process.env.UNI_INPUT_DIR,
              chunk.facadeModuleId
            )
            return slash(filepath.replace(path.extname(filepath), '.js'))
          }
          return '[name].js'
        },
        assetFileNames: '[name][extname]',
        globals: {
          vue: 'Vue',
        },
fxy060608's avatar
fxy060608 已提交
31 32
      },
    },
33
  }
fxy060608's avatar
fxy060608 已提交
34
}