index.js 1.0 KB
Newer Older
fxy060608's avatar
fxy060608 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
const {
  manifestPlatformOptions
} = require('./lib/env')

const {
  assetsDir
} = require('./lib/copy-webpack-options')

require('./lib/check-update')()

const initBuildCommand = require('./commands/build')
const initServeCommand = require('./commands/serve')

module.exports = (api, options) => {
  initServeCommand(api, options)

  initBuildCommand(api, options)

  const platformOptions = require('./lib/' + process.env.UNI_PLATFORM)

fxy060608's avatar
fxy060608 已提交
21
  Object.assign(options, { // TODO 考虑非 HBuilderX 运行时,可以支持自定义输出目录
fxy060608's avatar
fxy060608 已提交
22 23 24 25 26 27
    outputDir: process.env.UNI_OUTPUT_TMP_DIR || process.env.UNI_OUTPUT_DIR,
    assetsDir
  }, platformOptions.vueConfig)

  require('./lib/options')(options)

fxy060608's avatar
fxy060608 已提交
28 29
  api.configureWebpack(require('./lib/configure-webpack')(platformOptions, manifestPlatformOptions, options, api))
  api.chainWebpack(require('./lib/chain-webpack')(platformOptions, api))
fxy060608's avatar
fxy060608 已提交
30 31 32
}

module.exports.defaultModes = {
fxy060608's avatar
fxy060608 已提交
33 34
  'uni-serve': 'development',
  'uni-build': process.env.NODE_ENV
fxy060608's avatar
fxy060608 已提交
35
}