uni.config.js 1.6 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 30 31 32 33 34 35 36 37 38 39 40 41 42
      'sitemap.json',
      'ext.json',
      'custom-tab-bar'
    ]
    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 已提交
43 44 45 46 47 48 49 50 51 52
    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 已提交
53 54 55
    return copyOptions
  }
}