UNPKG

1.94 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 });
11exports.default = (ctx, opts) => {
12 ctx.registerPlatform({
13 name: 'tt',
14 useConfigName: 'mini',
15 fn({ config }) {
16 return __awaiter(this, void 0, void 0, function* () {
17 const { appPath, nodeModulesPath, outputPath } = ctx.paths;
18 const { npm, emptyDirectory } = ctx.helper;
19 emptyDirectory(outputPath);
20 // 生成 project.config.json
21 ctx.generateProjectConfig({
22 srcConfigName: 'project.tt.json',
23 distConfigName: 'project.config.json'
24 });
25 // 准备 miniRunner 参数
26 const miniRunnerOpts = Object.assign({}, config, { nodeModulesPath, buildAdapter: config.platform, isBuildPlugin: false, globalObject: 'tt', fileType: {
27 templ: '.ttml',
28 style: '.ttss',
29 config: '.json',
30 script: '.js'
31 }, isUseComponentBuildPage: false });
32 // build with webpack
33 const miniRunner = yield npm.getNpmPkg('@tarojs/mini-runner', appPath);
34 yield miniRunner(appPath, miniRunnerOpts);
35 });
36 }
37 });
38};