rollup.config.app.js 1.7 KB
Newer Older
fxy060608's avatar
fxy060608 已提交
1 2
const path = require('path')
const alias = require('rollup-plugin-alias')
fxy060608's avatar
fxy060608 已提交
3
const replace = require('rollup-plugin-replace')
fxy060608's avatar
fxy060608 已提交
4 5
const resolve = require('rollup-plugin-node-resolve')
const commonjs = require('rollup-plugin-commonjs')
fxy060608's avatar
fxy060608 已提交
6 7
const requireContext = require('./rollup-plugin-require-context')

fxy060608's avatar
fxy060608 已提交
8
let input = 'src/platforms/app-plus/service/uni/create-instance-context.js'
fxy060608's avatar
fxy060608 已提交
9 10 11 12 13 14 15 16 17 18

const output = {
  file: 'packages/uni-app-plus-nvue/dist/index.js',
  format: 'es'
}

if (process.env.UNI_SERVICE === 'legacy') {
  input = 'src/platforms/app-plus-nvue/service/index.legacy.js'
  output.file = 'packages/uni-app-plus-nvue/dist/index.legacy.js'
} else if (process.env.UNI_SERVICE === 'uni') {
fxy060608's avatar
fxy060608 已提交
19
  input = 'src/platforms/app-plus/service/uni/index.js'
fxy060608's avatar
fxy060608 已提交
20
  output.file = 'packages/uni-app-plus-nvue/dist/uni.js'
fxy060608's avatar
fxy060608 已提交
21 22 23 24
  output.banner =
`export function createUniInstance(weex, plus, __uniConfig, __uniRoutes, UniServiceJSBridge, getApp, getCurrentPages){
var localStorage = plus.storage
`
fxy060608's avatar
fxy060608 已提交
25 26
  output.footer = '\n  return uni$1 \n}'
}
fxy060608's avatar
fxy060608 已提交
27 28

module.exports = {
fxy060608's avatar
fxy060608 已提交
29 30
  input,
  output,
fxy060608's avatar
fxy060608 已提交
31
  plugins: [
fxy060608's avatar
fxy060608 已提交
32 33
    resolve(),
    commonjs(),
fxy060608's avatar
fxy060608 已提交
34
    requireContext(),
fxy060608's avatar
fxy060608 已提交
35
    alias({
fxy060608's avatar
fxy060608 已提交
36 37
      'uni-core': path.resolve(__dirname, '../src/core'),
      'uni-platform': path.resolve(__dirname, '../src/platforms/' + process.env.UNI_PLATFORM),
fxy060608's avatar
fxy060608 已提交
38 39 40
      'uni-platforms': path.resolve(__dirname, '../src/platforms'),
      'uni-shared': path.resolve(__dirname, '../src/shared/util.js'),
      'uni-helpers': path.resolve(__dirname, '../src/core/helpers')
fxy060608's avatar
fxy060608 已提交
41 42 43
    }),
    replace({
      __GLOBAL__: 'getGlobalUni()',
fxy060608's avatar
fxy060608 已提交
44
      __PLATFORM__: JSON.stringify(process.env.UNI_PLATFORM),
fxy060608's avatar
fxy060608 已提交
45 46
      __PLATFORM_TITLE__: 'app-plus-nvue'
    })
fxy060608's avatar
fxy060608 已提交
47 48
  ],
  external: ['./uni']
fxy060608's avatar
fxy060608 已提交
49
}