| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265 |
- 'use strict';
- var uniCliShared = require('@dcloudio/uni-cli-shared');
- var initMiniProgramPlugin = require('@dcloudio/uni-mp-vite');
- var path = require('path');
- var compilerCore = require('@vue/compiler-core');
- function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
- var initMiniProgramPlugin__default = /*#__PURE__*/_interopDefault(initMiniProgramPlugin);
- var path__default = /*#__PURE__*/_interopDefault(path);
- var uniad_app_json = function (appJson) {
- if (!appJson.plugins) {
- appJson.plugins = {};
- }
- if (!appJson.plugins['uni-ad']) {
- appJson.plugins['uni-ad'] = {
- version: '1.1.10',
- provider: 'wxf72d316417b6767f',
- };
- }
- if (!appJson.plugins['coral-adv']) {
- appJson.plugins['coral-adv'] = {
- version: '1.0.18',
- provider: 'wx0e203209e27b1e66',
- };
- }
- if (!appJson.usingComponents) {
- appJson.usingComponents = {};
- }
- if (!appJson.usingComponents['uniad-plugin']) {
- appJson.usingComponents['uniad-plugin'] = 'plugin://uni-ad/ad';
- }
- };
- var uniadAppJson = uniad_app_json;
- const AD_COMPONENTS = [
- 'uniad',
- 'ad-rewarded-video',
- 'ad-fullscreen-video',
- 'ad-interstitial',
- ];
- let appJsonUniadFlag = false;
- function transformAd(node, context) {
- if (!uniCliShared.isElementNode(node)) {
- return;
- }
- const adpidProp = compilerCore.findProp(node, 'adpid');
- if (node.tag === 'ad' && adpidProp) {
- node.tag = 'uniad';
- node.tagType = 1 /* ElementTypes.COMPONENT */;
- }
- if (appJsonUniadFlag) {
- return;
- }
- if (AD_COMPONENTS.indexOf(node.tag) > -1) {
- appJsonUniadFlag = true;
- uniadAppJson(uniCliShared.findJsonFile('app'));
- }
- }
- var description = "项目配置文件。";
- var packOptions = {
- ignore: [
- ]
- };
- var setting = {
- urlCheck: false,
- es6: true,
- postcss: false,
- minified: false,
- newFeature: true,
- bigPackageSizeSupport: true
- };
- var compileType = "miniprogram";
- var libVersion = "";
- var appid = "touristappid";
- var projectname = "";
- var condition = {
- search: {
- current: -1,
- list: [
- ]
- },
- conversation: {
- current: -1,
- list: [
- ]
- },
- game: {
- current: -1,
- list: [
- ]
- },
- miniprogram: {
- current: -1,
- list: [
- ]
- }
- };
- var source = {
- description: description,
- packOptions: packOptions,
- setting: setting,
- compileType: compileType,
- libVersion: libVersion,
- appid: appid,
- projectname: projectname,
- condition: condition
- };
- const customElements = [
- 'page-container',
- 'page-meta',
- 'navigation-bar',
- 'match-media',
- 'ad-custom',
- 'share-element',
- 'channel-live',
- 'channel-video',
- 'voip-room',
- 'root-portal',
- 'subscribe',
- // 手势组件
- 'tap-gesture-handler',
- 'double-tap-gesture-handler',
- 'scale-gesture-handler',
- 'force-press-gesture-handler',
- 'pan-gesture-handler',
- 'vertical-drag-gesture-handler',
- 'horizontal-drag-gesture-handler',
- 'long-press-gesture-handler',
- 'grid-view',
- 'list-view',
- 'sticky-header',
- 'sticky-section',
- ];
- const compilerOptions = {
- nodeTransforms: [uniCliShared.transformRef, uniCliShared.transformComponentLink, transformAd],
- };
- const COMPONENTS_DIR = 'wxcomponents';
- const miniProgram = {
- class: {
- array: true,
- },
- slot: {
- fallbackContent: false,
- dynamicSlotNames: true,
- },
- event: {
- key: true,
- },
- directive: 'wx:',
- lazyElement: {
- canvas: [
- { name: 'bind', arg: ['canvas-id', 'id'] },
- {
- name: 'on',
- arg: ['touchstart', 'touchmove', 'touchcancel', 'touchend'],
- },
- ],
- editor: [
- {
- name: 'on',
- arg: ['ready'],
- },
- ],
- 'scroll-view': [
- {
- name: 'on',
- arg: ['dragstart', 'dragging', 'dragend'],
- },
- ],
- // iOS 平台需要延迟
- input: [{ name: 'bind', arg: ['type'] }],
- textarea: [{ name: 'on', arg: ['input'] }],
- },
- component: {
- dir: COMPONENTS_DIR,
- vShow: uniCliShared.COMPONENT_CUSTOM_HIDDEN,
- getPropertySync: false,
- normalizeName: (name) => name.startsWith('wx-') ? name.replace('wx-', 'weixin-') : name,
- },
- };
- const projectConfigFilename = 'project.config.json';
- const options = {
- cdn: 1,
- vite: {
- inject: {
- uni: [path__default.default.resolve(__dirname, 'uni.api.esm.js'), 'default'],
- wx: [path__default.default.resolve(__dirname, 'uni.api.esm.js'), 'wx'],
- },
- alias: {
- 'uni-mp-runtime': path__default.default.resolve(__dirname, 'uni.mp.esm.js'),
- },
- copyOptions: {
- assets: [COMPONENTS_DIR],
- targets: [
- ...(process.env.UNI_MP_PLUGIN ? [uniCliShared.copyMiniProgramPluginJson] : []),
- {
- src: [
- 'sitemap.json',
- 'ext.json',
- 'custom-tab-bar',
- 'functional-pages',
- 'project.private.config.json',
- projectConfigFilename,
- ],
- get dest() {
- return process.env.UNI_OUTPUT_DIR;
- },
- },
- ...uniCliShared.copyMiniProgramThemeJson(),
- ],
- },
- },
- global: 'wx',
- app: {
- darkmode: true,
- subpackages: true,
- plugins: true,
- usingComponents: true,
- },
- project: {
- filename: projectConfigFilename,
- config: ['project.wx.json', 'project.config.json'],
- source,
- },
- template: Object.assign(Object.assign({}, miniProgram), { customElements, filter: {
- extname: '.wxs',
- lang: 'wxs',
- generate(filter, filename) {
- if (filename) {
- return `<wxs src="${filename}.wxs" module="${filter.name}"/>`;
- }
- return `<wxs module="${filter.name}">
- ${filter.code}
- </wxs>`;
- },
- }, extname: '.wxml', compilerOptions }),
- style: {
- extname: '.wxss',
- },
- };
- const uniMiniProgramWeixinPlugin = {
- name: 'uni:mp-weixin',
- config() {
- return {
- define: {
- __VUE_CREATED_DEFERRED__: false,
- },
- build: {
- // css 中不支持引用本地资源
- assetsInlineLimit: uniCliShared.ASSETS_INLINE_LIMIT,
- },
- };
- },
- };
- var index = [uniMiniProgramWeixinPlugin, ...initMiniProgramPlugin__default.default(options)];
- module.exports = index;
|