vite.config.ts 1.2 KB
Newer Older
fxy060608's avatar
fxy060608 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14
import path from 'path'

import replace from '@rollup/plugin-replace'

import { isCustomElement } from '../uni-shared'

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

export default {
  root: '.',
  minify: false,
  assetsDir: '.',
fxy060608's avatar
fxy060608 已提交
15
  emitAssets: false,
fxy060608's avatar
fxy060608 已提交
16 17 18
  alias: {
    '@dcloudio/uni-api': resolve('../uni-api/src/index.ts'),
    '@dcloudio/uni-vue': resolve('../uni-vue/src/index.ts'),
fxy060608's avatar
fxy060608 已提交
19 20
    '@dcloudio/uni-core': resolve('../uni-core/src/index.ts'),
    '@dcloudio/uni-components': resolve('../uni-components/src/index.ts')
fxy060608's avatar
fxy060608 已提交
21 22 23 24 25 26 27 28 29 30 31
  },
  define: {
    global: 'window',
    __DEV__: `(process.env.NODE_ENV !== 'production')`,
    __PLATFORM__: JSON.stringify('h5')
  },
  vueCompilerOptions: {
    isCustomElement
  },
  rollupInputOptions: {
    input: 'src/index.ts',
fxy060608's avatar
fxy060608 已提交
32
    external: ['vue', 'vue-router', '@vue/shared', '@dcloudio/uni-shared'],
fxy060608's avatar
fxy060608 已提交
33 34 35 36 37 38 39 40 41
    preserveEntrySignatures: 'strict',
    plugins: [
      replace({
        createApi: `/*#__PURE__*/ createApi`
      })
    ]
  },
  rollupOutputOptions: {
    format: 'es',
42 43 44 45 46 47 48
    entryFileNames: 'uni-h5.esm.js',
    assetFileNames(assetInfo) {
      if (assetInfo.name === 'style.css') {
        return 'uni-h5.css'
      }
      return 'assets/[name]-[hash][extname]'
    }
fxy060608's avatar
fxy060608 已提交
49 50
  }
}