uni.config.js 1.7 KB
Newer Older
fxy060608's avatar
fxy060608 已提交
1 2 3 4 5 6 7 8 9 10
const fs = require('fs')
const path = require('path')

const COMPONENTS_DIR_NAME = 'wxcomponents'

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

Q
qiang 已提交
34
    if (process.env.UNI_MP_PLUGIN) copyOptions.push('plugin.json')
D
DCloud_LXH 已提交
35

fxy060608's avatar
fxy060608 已提交
36 37 38 39 40 41 42 43 44 45 46
    const workers = platformOptions.workers
    workers && copyOptions.push(workers)

    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 已提交
47 48 49 50 51 52 53 54 55 56
    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 已提交
57 58
    return copyOptions
  }
59
}