“cdefe90ecca96dbbc50ece8679929dd182418cb0”上不存在“git@gitcode.net:ZY__520/megengine.git”
uni.config.js 2.2 KB
Newer Older
fxy060608's avatar
fxy060608 已提交
1 2
const fs = require('fs')
const path = require('path')
3
const { parseJson } = require('@dcloudio/uni-cli-shared/lib/json')
fxy060608's avatar
fxy060608 已提交
4 5 6 7 8 9 10 11

const COMPONENTS_DIR_NAME = 'wxcomponents'

module.exports = {
  options: {
    cssVars: {
      '--status-bar-height': '25px',
      '--window-top': '0px',
fxy060608's avatar
fxy060608 已提交
12 13
      '--window-bottom': '0px',
      '--window-left': '0px',
fxy060608's avatar
fxy060608 已提交
14
      '--window-right': '0px'
fxy060608's avatar
fxy060608 已提交
15 16 17 18 19 20 21 22
    },
    extnames: {
      style: '.wxss',
      template: '.wxml',
      filter: '.wxs'
    },
    filterTag: 'wxs',
    project: 'project.config.json',
fxy060608's avatar
fxy060608 已提交
23 24
    subPackages: true,
    darkmode: true
fxy060608's avatar
fxy060608 已提交
25 26
  },
  copyWebpackOptions (platformOptions, vueOptions) {
fxy060608's avatar
fxy060608 已提交
27
    const copyOptions = [
fxy060608's avatar
fxy060608 已提交
28
      'theme.json',
fxy060608's avatar
fxy060608 已提交
29 30
      'sitemap.json',
      'ext.json',
31
      'custom-tab-bar',
fxy060608's avatar
fxy060608 已提交
32
      'functional-pages'
fxy060608's avatar
fxy060608 已提交
33
    ]
D
DCloud_LXH 已提交
34

D
DCloud_LXH 已提交
35 36 37 38
    if (process.env.UNI_MP_PLUGIN) {
      copyOptions.push({
        from: path.resolve(process.env.UNI_INPUT_DIR, 'plugin.json'),
        transform: content => JSON.stringify(parseJson(content.toString(), true))
39
      })
D
DCloud_LXH 已提交
40
    }
D
DCloud_LXH 已提交
41

fxy060608's avatar
fxy060608 已提交
42 43 44
    const workers = platformOptions.workers
    workers && copyOptions.push(workers)

45 46 47 48 49 50 51 52 53 54 55 56 57
    const manifestConfig = process.UNI_MANIFEST;
    const weixinConfig = manifestConfig['mp-weixin'] || {};
    const copyWxComponentsOnDemandSwitch = !!weixinConfig.copyWxComponentsOnDemandSwitch; // 默认值false

    if (!copyWxComponentsOnDemandSwitch) {
      const wxcomponentsDir = path.resolve(process.env.UNI_INPUT_DIR, COMPONENTS_DIR_NAME);
      if (fs.existsSync(wxcomponentsDir)) {
        copyOptions.push({
          from: wxcomponentsDir,
          to: COMPONENTS_DIR_NAME,
          ignore: ['**/*.vue', '**/*.css'] // v3 会自动转换生成vue,css文件,需要过滤
        });
      }
fxy060608's avatar
fxy060608 已提交
58
    }
fxy060608's avatar
fxy060608 已提交
59 60 61 62 63 64 65 66 67 68
    global.uniModules.forEach(module => {
      const wxcomponentsDir = path.resolve(process.env.UNI_INPUT_DIR, 'uni_modules', module, COMPONENTS_DIR_NAME)
      if (fs.existsSync(wxcomponentsDir)) {
        copyOptions.push({
          from: wxcomponentsDir,
          to: 'uni_modules/' + module + '/' + COMPONENTS_DIR_NAME,
          ignore: ['**/*.vue', '**/*.css'] // v3 会自动转换生成vue,css文件,需要过滤
        })
      }
    })
fxy060608's avatar
fxy060608 已提交
69 70
    return copyOptions
  }
71
}