UNPKG

2.76 kBJavaScriptView Raw
1"use strict";
2var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3 return new (P || (P = Promise))(function (resolve, reject) {
4 function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5 function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6 function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
7 step((generator = generator.apply(thisArg, _arguments || [])).next());
8 });
9};
10Object.defineProperty(exports, "__esModule", { value: true });
11// const LOG_MAP = {
12// [BUILD_TYPES.WEAPP]: {
13// OPEN: '请打开微信小程序开发者工具进行查看'
14// },
15// [BUILD_TYPES.ALIPAY]: {
16// OPEN: '请打开支付宝小程序开发者工具进行查看'
17// },
18// [BUILD_TYPES.QQ]: {
19// OPEN: '请打开 QQ 小程序开发者工具进行查看'
20// },
21// [BUILD_TYPES.SWAN]: {
22// OPEN: '请打开百度智能小程序开发者工具进行查看'
23// },
24// [BUILD_TYPES.TT]: {
25// OPEN: '请打开字节跳动小程序开发者工具进行查看'
26// },
27// [BUILD_TYPES.JD]: {
28// OPEN: '请打开京东小程序开发者工具进行查看'
29// },
30// [BUILD_TYPES.QUICKAPP]: {
31// OPEN: '请按快应用端开发流程 https://taro-docs.jd.com/taro/docs/quick-app.html 进行查看'
32// }
33// }
34// swan page component true
35exports.default = (ctx) => {
36 ctx.registerPlatform({
37 name: 'weapp',
38 useConfigName: 'mini',
39 fn({ config }) {
40 return __awaiter(this, void 0, void 0, function* () {
41 const { appPath, nodeModulesPath, outputPath } = ctx.paths;
42 const { npm, emptyDirectory } = ctx.helper;
43 emptyDirectory(outputPath);
44 // 生成 project.config.json
45 ctx.generateProjectConfig({
46 srcConfigName: 'project.config.json',
47 distConfigName: 'project.config.json'
48 });
49 // 准备 miniRunner 参数
50 const miniRunnerOpts = Object.assign({}, config, { nodeModulesPath, buildAdapter: config.platform, isBuildPlugin: false, globalObject: 'wx', fileType: {
51 templ: '.wxml',
52 style: '.wxss',
53 config: '.json',
54 script: '.js'
55 }, isUseComponentBuildPage: true });
56 // build with webpack
57 const miniRunner = yield npm.getNpmPkg('@tarojs/mini-runner', appPath);
58 yield miniRunner(appPath, miniRunnerOpts);
59 });
60 }
61 });
62};