rollup.config.mp.js 1.8 KB
Newer Older
fxy060608's avatar
fxy060608 已提交
1
const path = require('path')
fxy060608's avatar
fxy060608 已提交
2 3
const alias = require('@rollup/plugin-alias')
const replace = require('@rollup/plugin-replace')
fxy060608's avatar
fxy060608 已提交
4

fxy060608's avatar
fxy060608 已提交
5 6 7 8
const PLATFORMS = {
  'mp-weixin': {
    prefix: 'wx',
    title: '微信小程序'
fxy060608's avatar
fxy060608 已提交
9 10 11 12
  },
  'mp-qq': {
    prefix: 'wx',
    title: 'QQ小程序'
fxy060608's avatar
fxy060608 已提交
13 14 15 16 17 18 19 20
  },
  'mp-alipay': {
    prefix: 'my',
    title: '支付宝小程序'
  },
  'mp-baidu': {
    prefix: 'swan',
    title: '百度小程序'
21 22 23 24
  },
  'mp-toutiao': {
    prefix: 'tt',
    title: '头条小程序'
25
  },
fxy060608's avatar
fxy060608 已提交
26
  'quickapp-webview': {
fxy060608's avatar
fxy060608 已提交
27
    prefix: 'qa',
fxy060608's avatar
fxy060608 已提交
28
    title: '快应用(Webview)版'
fxy060608's avatar
fxy060608 已提交
29
  },
30 31 32
  'app-plus': {
    prefix: 'wx',
    title: 'app-plus'
fxy060608's avatar
fxy060608 已提交
33
  }
fxy060608's avatar
fxy060608 已提交
34
}
fxy060608's avatar
fxy060608 已提交
35 36

const platform = PLATFORMS[process.env.UNI_PLATFORM]
37

fxy060608's avatar
fxy060608 已提交
38 39 40 41 42 43 44 45 46 47 48
let input = 'src/core/runtime/index.js'
const output = {
  file: `packages/uni-${process.env.UNI_PLATFORM}/dist/index.js`,
  format: 'es'
}

if (process.env.UNI_MP) {
  input = 'src/core/runtime/mp/index.js'
  output.file = `packages/uni-${process.env.UNI_PLATFORM}/dist/mp.js`
}

fxy060608's avatar
fxy060608 已提交
49
module.exports = {
fxy060608's avatar
fxy060608 已提交
50 51
  input,
  output,
fxy060608's avatar
fxy060608 已提交
52 53
  plugins: [
    alias({
fxy060608's avatar
fxy060608 已提交
54 55 56 57 58 59 60 61 62 63 64 65 66
      entries: [{
        find: 'uni-shared',
        replacement: path.resolve(__dirname, '../src/shared/util.js')
      }, {
        find: 'uni-platform',
        replacement: path.resolve(__dirname, '../src/platforms/' + process.env.UNI_PLATFORM)
      }, {
        find: 'uni-wrapper',
        replacement: path.resolve(__dirname, '../src/core/runtime/wrapper')
      }, {
        find: 'uni-helpers',
        replacement: path.resolve(__dirname, '../src/core/helpers')
      }]
fxy060608's avatar
fxy060608 已提交
67 68
    }),
    replace({
fxy060608's avatar
fxy060608 已提交
69
      __GLOBAL__: platform.prefix,
fxy060608's avatar
fxy060608 已提交
70
      __PLATFORM_TITLE__: platform.title,
fxy060608's avatar
fxy060608 已提交
71
      __PLATFORM_PREFIX__: JSON.stringify(platform.prefix),
fxy060608's avatar
fxy060608 已提交
72
      __PLATFORM__: JSON.stringify(process.env.UNI_PLATFORM)
fxy060608's avatar
fxy060608 已提交
73
    })
74 75
  ],
  external: ['vue']
fxy060608's avatar
fxy060608 已提交
76
}