options.ts 1.3 KB
Newer Older
fxy060608's avatar
fxy060608 已提交
1
import path from 'path'
2 3 4
import {
  COMPONENT_BIND_LINK,
  createTransformComponentLink,
fxy060608's avatar
fxy060608 已提交
5
  transformRef,
6
} from '@dcloudio/uni-cli-shared'
fxy060608's avatar
fxy060608 已提交
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
import { UniMiniProgramPluginOptions } from '@dcloudio/uni-mp-vite'

import source from './project.config.json'

const projectConfigFilename = 'project.config.json'

export const options: UniMiniProgramPluginOptions = {
  vite: {
    inject: {
      uni: [path.resolve(__dirname, 'uni.api.esm.js'), 'default'],
    },
    alias: {
      'uni-mp-runtime': path.resolve(__dirname, 'uni.mp.esm.js'),
    },
    copyOptions: {
      assets: ['ttcomponents'],
    },
  },
  global: 'tt',
  app: {
    darkmode: false,
    subpackages: true,
  },
  project: {
    filename: projectConfigFilename,
    source,
  },
  template: {
    class: {
      array: false,
    },
    filter: {
      extname: '.sjs',
      lang: 'sjs',
      generate(filter, filename) {
        if (filename) {
          return `<sjs src="${filename}.sjs" module="${filter.name}"/>`
        }
        return `<sjs module="${filter.name}">
${filter.code}
</sjs>`
      },
    },
    slot: {
51
      fallback: true,
fxy060608's avatar
fxy060608 已提交
52 53 54 55
    },
    extname: '.ttml',
    directive: 'tt:',
    compilerOptions: {
fxy060608's avatar
fxy060608 已提交
56 57 58 59
      nodeTransforms: [
        transformRef,
        createTransformComponentLink(COMPONENT_BIND_LINK),
      ],
fxy060608's avatar
fxy060608 已提交
60 61 62 63 64 65
    },
  },
  style: {
    extname: '.ttss',
  },
}