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/framework/create-instance-context.js'
fxy060608's avatar
fxy060608 已提交
9 10 11 12 13 14

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

fxy060608's avatar
fxy060608 已提交
15 16
const external = []

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

module.exports = {
fxy060608's avatar
fxy060608 已提交
33 34
  input,
  output,
fxy060608's avatar
fxy060608 已提交
35
  plugins: [
fxy060608's avatar
fxy060608 已提交
36 37
    resolve(),
    commonjs(),
fxy060608's avatar
fxy060608 已提交
38
    requireContext(),
fxy060608's avatar
fxy060608 已提交
39
    alias({
fxy060608's avatar
fxy060608 已提交
40
      'uni-core': path.resolve(__dirname, '../src/core'),
fxy060608's avatar
fxy060608 已提交
41
      'uni-platform': path.resolve(__dirname, '../src/platforms/app-plus'),
fxy060608's avatar
fxy060608 已提交
42 43 44
      '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 已提交
45 46 47
    }),
    replace({
      __GLOBAL__: 'getGlobalUni()',
fxy060608's avatar
fxy060608 已提交
48
      __PLATFORM__: JSON.stringify('app-plus'),
fxy060608's avatar
fxy060608 已提交
49 50
      __PLATFORM_TITLE__: 'app-plus-nvue'
    })
fxy060608's avatar
fxy060608 已提交
51
  ],
fxy060608's avatar
fxy060608 已提交
52
  external
fxy060608's avatar
fxy060608 已提交
53
}