@weapp-tailwindcss/cli 0.0.0-alpha.6 → 0.0.0-alpha.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -11,6 +11,10 @@ const gulp = require('weapp-tailwindcss/gulp');
11
11
  const postcssrc = require('gulp-postcss');
12
12
  const plumber = require('gulp-plumber');
13
13
  const gulpif = require('gulp-if');
14
+ const createSass = require('gulp-sass');
15
+ const rename = require('gulp-rename');
16
+ const less = require('gulp-less');
17
+ const typescript = require('gulp-typescript');
14
18
  const cosmiconfig = require('cosmiconfig');
15
19
 
16
20
  function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; }
@@ -24,6 +28,10 @@ const createDebug__default = /*#__PURE__*/_interopDefaultCompat(createDebug);
24
28
  const postcssrc__default = /*#__PURE__*/_interopDefaultCompat(postcssrc);
25
29
  const plumber__default = /*#__PURE__*/_interopDefaultCompat(plumber);
26
30
  const gulpif__default = /*#__PURE__*/_interopDefaultCompat(gulpif);
31
+ const createSass__default = /*#__PURE__*/_interopDefaultCompat(createSass);
32
+ const rename__default = /*#__PURE__*/_interopDefaultCompat(rename);
33
+ const less__default = /*#__PURE__*/_interopDefaultCompat(less);
34
+ const typescript__default = /*#__PURE__*/_interopDefaultCompat(typescript);
27
35
 
28
36
  function isPlainObject$2(value) {
29
37
  if (value === null || typeof value !== "object") {
@@ -91,263 +99,6 @@ var AssetType = /* @__PURE__ */ ((AssetType2) => {
91
99
  return AssetType2;
92
100
  })(AssetType || {});
93
101
 
94
- function getTasks(options) {
95
- const { root: cwd, weappTailwindcssOptions, outDir, src: srcBase, extensions, exclude, include, postcssOptions } = options;
96
- const globsSet = /* @__PURE__ */ new Set();
97
- const base = srcBase ? srcBase + "/" : "";
98
- function globsSetAdd(...value) {
99
- for (const v of value) {
100
- if (Array.isArray(v)) {
101
- for (const vv of v) {
102
- globsSet.add(vv);
103
- }
104
- } else {
105
- globsSet.add(v);
106
- }
107
- }
108
- }
109
- function getGlobs(type) {
110
- const globs = [];
111
- if (typeof include === "function") {
112
- globs.push(...include(type).map((x) => x));
113
- }
114
- if (typeof exclude === "function") {
115
- globs.push(...exclude(type).map((x) => "!" + x));
116
- } else if (Array.isArray(exclude)) {
117
- globs.push(...exclude.map((x) => "!" + x));
118
- }
119
- globs.push(`!${outDir}/**/*`);
120
- return globs;
121
- }
122
- const { transformJs, transformWxml, transformWxss } = gulp.createPlugins(weappTailwindcssOptions);
123
- function getJsTasks() {
124
- const assetType = AssetType.JavaScript;
125
- const globs = getGlobs(assetType);
126
- globsSetAdd(globs);
127
- return extensions[assetType].map((x) => {
128
- const src = `${base}**/*.${x}`;
129
- globsSetAdd(src);
130
- return function JsTask() {
131
- return gulp__default.src([src, ...globs], { cwd, since: gulp__default.lastRun(JsTask) }).pipe(plumber__default()).pipe(
132
- transformJs({
133
- babelParserOptions: x === "ts" ? {
134
- plugins: ["typescript"]
135
- } : void 0
136
- })
137
- ).pipe(
138
- gulp__default.dest(outDir, {
139
- cwd
140
- })
141
- );
142
- };
143
- });
144
- }
145
- function getJsonTasks() {
146
- const assetType = AssetType.Json;
147
- const globs = getGlobs(assetType);
148
- globsSetAdd(globs);
149
- return extensions[assetType].map((x) => {
150
- const src = `${base}**/*.${x}`;
151
- globsSetAdd(src);
152
- return function JsonTask() {
153
- return gulp__default.src([src, ...globs], { cwd, since: gulp__default.lastRun(JsonTask) }).pipe(plumber__default()).pipe(
154
- gulp__default.dest(outDir, {
155
- cwd
156
- })
157
- );
158
- };
159
- });
160
- }
161
- function getCssTasks() {
162
- const assetType = AssetType.Css;
163
- const globs = getGlobs(assetType);
164
- globsSetAdd(globs);
165
- return extensions[assetType].map((x) => {
166
- const src = `${base}**/*.${x}`;
167
- globsSetAdd(src);
168
- return function CssTask() {
169
- return gulp__default.src([src, ...globs], { cwd, since: gulp__default.lastRun(CssTask) }).pipe(plumber__default()).pipe(gulpif__default(Boolean(postcssOptions), postcssrc__default(postcssOptions?.plugins, postcssOptions?.options))).pipe(transformWxss()).pipe(
170
- gulp__default.dest(outDir, {
171
- cwd
172
- })
173
- );
174
- };
175
- });
176
- }
177
- function getHtmlTasks() {
178
- const assetType = AssetType.Html;
179
- const globs = getGlobs(assetType);
180
- globsSetAdd(globs);
181
- return extensions[assetType].map((x) => {
182
- const src = `${base}**/*.${x}`;
183
- globsSetAdd(src);
184
- return function HtmlTask() {
185
- return gulp__default.src([src, ...globs], { cwd, since: gulp__default.lastRun(HtmlTask) }).pipe(plumber__default()).pipe(transformWxml()).pipe(
186
- gulp__default.dest(outDir, {
187
- cwd
188
- })
189
- );
190
- };
191
- });
192
- }
193
- function copyOthers() {
194
- if (Array.isArray(include)) {
195
- const globs = include.map((x) => {
196
- return `${base}${x}`;
197
- });
198
- globsSetAdd(globs);
199
- return gulp__default.src(globs, { cwd, since: gulp__default.lastRun(copyOthers) }).pipe(plumber__default()).pipe(
200
- gulp__default.dest(outDir, {
201
- cwd
202
- })
203
- );
204
- }
205
- }
206
- return {
207
- getGlobs,
208
- getJsTasks,
209
- getJsonTasks,
210
- getCssTasks,
211
- getHtmlTasks,
212
- copyOthers,
213
- globsSet
214
- };
215
- }
216
-
217
- const defaultJavascriptExtensions = ["js"];
218
- const defaultTypescriptExtensions = ["ts"];
219
- const defaultWxsExtensions = ["wxs"];
220
- const defaultNodeModulesDirs = [
221
- "**/node_modules/**",
222
- "**/miniprogram_npm/**",
223
- "**/project.config.json/**",
224
- "**/project.private.config.json/**",
225
- "**/package.json/**",
226
- "postcss.config.js",
227
- "tailwind.config.js"
228
- ];
229
- function createBuilder(options) {
230
- const {
231
- root: cwd,
232
- weappTailwindcssOptions,
233
- outDir,
234
- src: srcBase,
235
- clean,
236
- extensions,
237
- exclude,
238
- include,
239
- watchOptions,
240
- postcssOptions
241
- } = defu(options, {
242
- outDir: "dist",
243
- weappTailwindcssOptions: {},
244
- clean: true,
245
- src: "",
246
- exclude: [...defaultNodeModulesDirs],
247
- extensions: {
248
- javascript: [...defaultJavascriptExtensions, ...defaultTypescriptExtensions, ...defaultWxsExtensions],
249
- html: ["wxml"],
250
- css: ["wxss", "less", "sass", "scss"],
251
- json: ["json"]
252
- },
253
- watchOptions: {
254
- events: ["add", "change", "unlink", "ready"]
255
- }
256
- });
257
- const { copyOthers, getCssTasks, getHtmlTasks, getJsTasks, getJsonTasks, globsSet } = getTasks({
258
- root: cwd,
259
- weappTailwindcssOptions,
260
- outDir,
261
- src: srcBase,
262
- clean,
263
- extensions,
264
- exclude,
265
- include,
266
- watchOptions,
267
- postcssOptions
268
- });
269
- const tasks = {
270
- css: getCssTasks(),
271
- html: getHtmlTasks(),
272
- json: getJsonTasks(),
273
- js: getJsTasks(),
274
- extra: [copyOthers]
275
- };
276
- async function runTasks() {
277
- debug("run tasks start");
278
- for (const [key, value] of Object.entries(tasks)) {
279
- debug(`run task ${pc__default.bold(pc__default.green(key))} start`);
280
- for (const task of value) {
281
- const s = task();
282
- if (s) {
283
- await new Promise((resolve, reject) => s.on("finish", resolve).on("error", reject));
284
- }
285
- }
286
- debug(`run task ${pc__default.bold(pc__default.green(key))} end`);
287
- }
288
- debug("run tasks end");
289
- }
290
- return {
291
- watcher: void 0,
292
- async build() {
293
- if (clean) {
294
- debug("del start");
295
- const { deleteAsync } = await import('del');
296
- const patterns = [outDir + "/**"];
297
- await deleteAsync(patterns, { cwd, ignore: defaultNodeModulesDirs });
298
- debug("del end");
299
- }
300
- fs.ensureDirSync(path__default.resolve(cwd, outDir));
301
- await runTasks();
302
- return this;
303
- },
304
- watch() {
305
- fs.ensureDirSync(path__default.resolve(cwd, outDir));
306
- const watcher = gulp__default.watch([...globsSet], watchOptions, async (cb) => {
307
- try {
308
- await runTasks();
309
- cb();
310
- } catch (error) {
311
- cb(error);
312
- }
313
- });
314
- watcher.on("change", function(path2) {
315
- console.log(`${pc__default.green("changed")} ${path2}`);
316
- });
317
- watcher.on("add", function(path2) {
318
- console.log(`${pc__default.green("add")} ${path2}`);
319
- });
320
- watcher.on("unlink", function(path2) {
321
- console.log(`${pc__default.green("remove")} ${path2}`);
322
- });
323
- watcher.on("ready", function() {
324
- console.log(`${pc__default.green("weapp")}-${pc__default.blue("tailwindcss")} is ready!`);
325
- });
326
- this.watcher = watcher;
327
- return this;
328
- },
329
- globsSet
330
- };
331
- }
332
- async function build(options) {
333
- let postcssOptions;
334
- try {
335
- postcssOptions = await loadPostcssConfig__default({ cwd: options?.root });
336
- } catch {
337
- }
338
- const builder = createBuilder(defu(options, { postcssOptions }));
339
- return await builder.build();
340
- }
341
- async function watch(options) {
342
- let postcssOptions;
343
- try {
344
- postcssOptions = await loadPostcssConfig__default({ cwd: options?.root });
345
- } catch {
346
- }
347
- const builder = createBuilder(defu(options, { postcssOptions }));
348
- return await builder.watch();
349
- }
350
-
351
102
  function getDefaultExportFromCjs (x) {
352
103
  return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
353
104
  }
@@ -384,10 +135,10 @@ var isobject = function isObject(val) {
384
135
  * Released under the MIT License.
385
136
  */
386
137
 
387
- var isObject$2 = isobject;
138
+ var isObject$3 = isobject;
388
139
 
389
140
  function isObjectObject(o) {
390
- return isObject$2(o) === true
141
+ return isObject$3(o) === true
391
142
  && Object.prototype.toString.call(o) === '[object Object]';
392
143
  }
393
144
 
@@ -424,7 +175,7 @@ const { deleteProperty } = Reflect;
424
175
  const isPrimitive = isPrimitive$1;
425
176
  const isPlainObject = isPlainObject$1;
426
177
 
427
- const isObject$1 = value => {
178
+ const isObject$2 = value => {
428
179
  return (typeof value === 'object' && value !== null) || typeof value === 'function';
429
180
  };
430
181
 
@@ -542,7 +293,7 @@ const assignProp = (obj, prop, value, options) => {
542
293
  };
543
294
 
544
295
  const setValue = (target, path, value, options) => {
545
- if (!path || !isObject$1(target)) return target;
296
+ if (!path || !isObject$2(target)) return target;
546
297
 
547
298
  const keys = split$1(path, options);
548
299
  let obj = target;
@@ -563,7 +314,7 @@ const setValue = (target, path, value, options) => {
563
314
  continue;
564
315
  }
565
316
 
566
- if (!isObject$1(obj[key])) {
317
+ if (!isObject$2(obj[key])) {
567
318
  obj[key] = {};
568
319
  }
569
320
 
@@ -590,10 +341,10 @@ const set = /*@__PURE__*/getDefaultExportFromCjs(setValue_1);
590
341
  * Released under the MIT License.
591
342
  */
592
343
 
593
- const isObject = isobject;
344
+ const isObject$1 = isobject;
594
345
 
595
346
  var getValue = function(target, path, options) {
596
- if (!isObject(options)) {
347
+ if (!isObject$1(options)) {
597
348
  options = { default: options };
598
349
  }
599
350
 
@@ -691,11 +442,309 @@ function isValid(key, target, options) {
691
442
  }
692
443
 
693
444
  function isValidObject(val) {
694
- return isObject(val) || Array.isArray(val) || typeof val === 'function';
445
+ return isObject$1(val) || Array.isArray(val) || typeof val === 'function';
695
446
  }
696
447
 
697
448
  const get = /*@__PURE__*/getDefaultExportFromCjs(getValue);
698
449
 
450
+ function isObject(x) {
451
+ return typeof x === "object" && x !== null;
452
+ }
453
+
454
+ function isSassLang(lang) {
455
+ return lang === "scss" || lang === "sass";
456
+ }
457
+ function isLessLang(lang) {
458
+ return lang === "less";
459
+ }
460
+ function isTsLang(lang) {
461
+ return lang === "ts";
462
+ }
463
+ async function getTasks(options) {
464
+ let { typescriptOptions } = options;
465
+ const { root: cwd, weappTailwindcssOptions, outDir, src: srcBase, extensions, exclude, include, postcssOptions, preprocessorOptions } = options;
466
+ const globsSet = /* @__PURE__ */ new Set();
467
+ const base = srcBase ? srcBase + "/" : "";
468
+ const enableSass = Boolean(preprocessorOptions?.sass);
469
+ const enableLess = Boolean(preprocessorOptions?.less);
470
+ if (typescriptOptions === true) {
471
+ typescriptOptions = {
472
+ tsConfigFileName: "tsconfig.json"
473
+ };
474
+ } else if (isObject(typescriptOptions) && typescriptOptions.tsConfigFileName === void 0) {
475
+ typescriptOptions.tsConfigFileName = "tsconfig.json";
476
+ }
477
+ const enableTs = Boolean(typescriptOptions);
478
+ let sass;
479
+ if (enableSass) {
480
+ const sassLib = await import('sass');
481
+ sass = createSass__default(sassLib);
482
+ }
483
+ const { transformJs, transformWxml, transformWxss } = gulp.createPlugins(weappTailwindcssOptions);
484
+ function globsSetAdd(...value) {
485
+ for (const v of value) {
486
+ if (Array.isArray(v)) {
487
+ for (const vv of v) {
488
+ globsSet.add(vv);
489
+ }
490
+ } else {
491
+ globsSet.add(v);
492
+ }
493
+ }
494
+ }
495
+ function getGlobs(type) {
496
+ const globs = [];
497
+ if (typeof include === "function") {
498
+ globs.push(...include(type).map((x) => x));
499
+ }
500
+ if (typeof exclude === "function") {
501
+ globs.push(...exclude(type).map((x) => "!" + x));
502
+ } else if (Array.isArray(exclude)) {
503
+ globs.push(...exclude.map((x) => "!" + x));
504
+ }
505
+ globs.push(`!${outDir}/**/*`);
506
+ return globs;
507
+ }
508
+ function getJsTasks() {
509
+ const assetType = AssetType.JavaScript;
510
+ const globs = getGlobs(assetType);
511
+ globsSetAdd(globs);
512
+ return extensions[assetType]?.map((x) => {
513
+ const src = `${base}**/*.${x}`;
514
+ globsSetAdd(src);
515
+ const isTs = isTsLang(x);
516
+ const loadTs = enableTs && isTs;
517
+ let gulpTs;
518
+ if (enableTs && typeof typescriptOptions !== "boolean") {
519
+ gulpTs = typescript__default.createProject(typescriptOptions.tsConfigFileName ?? "tsconfig.json", typeof typescriptOptions === "boolean" ? {} : typescriptOptions);
520
+ }
521
+ return function JsTask() {
522
+ let chain = gulp__default.src([src, ...globs], { cwd, since: gulp__default.lastRun(JsTask) }).pipe(plumber__default());
523
+ if (loadTs) {
524
+ chain = chain.pipe(gulpTs());
525
+ }
526
+ return chain.pipe(
527
+ transformJs({
528
+ babelParserOptions: !enableTs && isTs ? {
529
+ plugins: ["typescript"]
530
+ } : void 0
531
+ })
532
+ ).pipe(
533
+ gulpif__default(
534
+ loadTs,
535
+ rename__default({
536
+ extname: ".js"
537
+ })
538
+ )
539
+ ).pipe(
540
+ gulp__default.dest(outDir, {
541
+ cwd
542
+ })
543
+ );
544
+ };
545
+ });
546
+ }
547
+ function getJsonTasks() {
548
+ const assetType = AssetType.Json;
549
+ const globs = getGlobs(assetType);
550
+ globsSetAdd(globs);
551
+ return extensions[assetType]?.map((x) => {
552
+ const src = `${base}**/*.${x}`;
553
+ globsSetAdd(src);
554
+ return function JsonTask() {
555
+ return gulp__default.src([src, ...globs], { cwd, since: gulp__default.lastRun(JsonTask) }).pipe(plumber__default()).pipe(
556
+ gulp__default.dest(outDir, {
557
+ cwd
558
+ })
559
+ );
560
+ };
561
+ });
562
+ }
563
+ function getCssTasks() {
564
+ const assetType = AssetType.Css;
565
+ const globs = getGlobs(assetType);
566
+ globsSetAdd(globs);
567
+ return extensions[assetType]?.map((x) => {
568
+ const src = `${base}**/*.${x}`;
569
+ globsSetAdd(src);
570
+ const loadSass = enableSass && isSassLang(x);
571
+ const loadLess = enableLess && isLessLang(x);
572
+ return function CssTask() {
573
+ let chain = gulp__default.src([src, ...globs], { cwd, since: gulp__default.lastRun(CssTask) }).pipe(plumber__default());
574
+ if (loadSass) {
575
+ chain = chain.pipe(
576
+ sass.sync(
577
+ // @ts-ignore
578
+ typeof preprocessorOptions?.sass === "boolean" ? void 0 : preprocessorOptions?.sass
579
+ ).on("error", sass.logError)
580
+ );
581
+ }
582
+ return chain.pipe(gulpif__default(loadLess, less__default(typeof preprocessorOptions?.less === "boolean" ? void 0 : preprocessorOptions?.less))).pipe(gulpif__default(Boolean(postcssOptions), postcssrc__default(postcssOptions?.plugins, postcssOptions?.options))).pipe(transformWxss()).pipe(
583
+ gulpif__default(
584
+ loadSass || loadLess,
585
+ rename__default({
586
+ extname: ".wxss"
587
+ })
588
+ )
589
+ ).pipe(
590
+ gulp__default.dest(outDir, {
591
+ cwd
592
+ })
593
+ );
594
+ };
595
+ });
596
+ }
597
+ function getHtmlTasks() {
598
+ const assetType = AssetType.Html;
599
+ const globs = getGlobs(assetType);
600
+ globsSetAdd(globs);
601
+ return extensions[assetType]?.map((x) => {
602
+ const src = `${base}**/*.${x}`;
603
+ globsSetAdd(src);
604
+ return function HtmlTask() {
605
+ return gulp__default.src([src, ...globs], { cwd, since: gulp__default.lastRun(HtmlTask) }).pipe(plumber__default()).pipe(transformWxml()).pipe(
606
+ gulp__default.dest(outDir, {
607
+ cwd
608
+ })
609
+ );
610
+ };
611
+ });
612
+ }
613
+ function copyOthers() {
614
+ if (Array.isArray(include)) {
615
+ const globs = include.map((x) => {
616
+ return `${base}${x}`;
617
+ });
618
+ globsSetAdd(globs);
619
+ return gulp__default.src(globs, { cwd, since: gulp__default.lastRun(copyOthers) }).pipe(plumber__default()).pipe(
620
+ gulp__default.dest(outDir, {
621
+ cwd
622
+ })
623
+ );
624
+ }
625
+ }
626
+ return {
627
+ getGlobs,
628
+ getJsTasks,
629
+ getJsonTasks,
630
+ getCssTasks,
631
+ getHtmlTasks,
632
+ copyOthers,
633
+ globsSet
634
+ };
635
+ }
636
+
637
+ const defaultJavascriptExtensions = ["js"];
638
+ const defaultTypescriptExtensions = ["ts"];
639
+ const defaultWxsExtensions = ["wxs"];
640
+ const defaultNodeModulesDirs = [
641
+ "**/node_modules/**",
642
+ "**/miniprogram_npm/**",
643
+ "**/project.config.json/**",
644
+ "**/project.private.config.json/**",
645
+ "**/package.json/**",
646
+ "postcss.config.js",
647
+ "tailwind.config.js"
648
+ ];
649
+ async function createBuilder(options) {
650
+ let postcssOptionsFromConfig;
651
+ try {
652
+ postcssOptionsFromConfig = await loadPostcssConfig__default({ cwd: options?.root });
653
+ } catch {
654
+ }
655
+ const opt = defu(options, {
656
+ outDir: "dist",
657
+ weappTailwindcssOptions: {},
658
+ clean: true,
659
+ src: "",
660
+ exclude: [...defaultNodeModulesDirs],
661
+ extensions: {
662
+ javascript: [...defaultJavascriptExtensions, ...defaultTypescriptExtensions, ...defaultWxsExtensions],
663
+ html: ["wxml"],
664
+ css: ["wxss", "less", "sass", "scss"],
665
+ json: ["json"]
666
+ },
667
+ watchOptions: {
668
+ events: ["add", "change", "unlink", "ready"]
669
+ },
670
+ postcssOptions: postcssOptionsFromConfig
671
+ });
672
+ const { copyOthers, getCssTasks, getHtmlTasks, getJsTasks, getJsonTasks, globsSet } = await getTasks(opt);
673
+ const tasks = {
674
+ css: getCssTasks(),
675
+ html: getHtmlTasks(),
676
+ json: getJsonTasks(),
677
+ js: getJsTasks(),
678
+ extra: [copyOthers]
679
+ };
680
+ async function runTasks() {
681
+ debug("run tasks start");
682
+ for (const [key, value] of Object.entries(tasks)) {
683
+ if (value) {
684
+ debug(`run task ${pc__default.bold(pc__default.green(key))} start`);
685
+ for (const task of value) {
686
+ const s = task();
687
+ if (s) {
688
+ await new Promise((resolve, reject) => s.on("finish", resolve).on("error", reject));
689
+ }
690
+ }
691
+ debug(`run task ${pc__default.bold(pc__default.green(key))} end`);
692
+ }
693
+ }
694
+ debug("run tasks end");
695
+ }
696
+ const { clean, outDir, root: cwd, watchOptions } = opt;
697
+ return {
698
+ watcher: void 0,
699
+ async build() {
700
+ if (clean) {
701
+ debug("del start");
702
+ const { deleteAsync } = await import('del');
703
+ const patterns = [outDir + "/**"];
704
+ await deleteAsync(patterns, { cwd, ignore: defaultNodeModulesDirs });
705
+ debug("del end");
706
+ }
707
+ fs.ensureDirSync(path__default.resolve(cwd, outDir));
708
+ await runTasks();
709
+ return this;
710
+ },
711
+ watch() {
712
+ fs.ensureDirSync(path__default.resolve(cwd, outDir));
713
+ const watcher = gulp__default.watch([...globsSet], watchOptions, async (cb) => {
714
+ try {
715
+ await runTasks();
716
+ cb();
717
+ } catch (error) {
718
+ cb(error);
719
+ }
720
+ });
721
+ watcher.on("change", function(path2) {
722
+ console.log(`${pc__default.green("changed")} ${path2}`);
723
+ });
724
+ watcher.on("add", function(path2) {
725
+ console.log(`${pc__default.green("add")} ${path2}`);
726
+ });
727
+ watcher.on("unlink", function(path2) {
728
+ console.log(`${pc__default.green("remove")} ${path2}`);
729
+ });
730
+ watcher.on("ready", function() {
731
+ console.log(`${pc__default.green("weapp")}-${pc__default.blue("tailwindcss")} is ready!`);
732
+ });
733
+ this.watcher = watcher;
734
+ return this;
735
+ },
736
+ globsSet
737
+ };
738
+ }
739
+ async function build(options) {
740
+ const builder = await createBuilder(options);
741
+ return await builder.build();
742
+ }
743
+ async function watch(options) {
744
+ const builder = await createBuilder(options);
745
+ return await builder.watch();
746
+ }
747
+
699
748
  function createConfigLoader(root) {
700
749
  const explorer = cosmiconfig.cosmiconfigSync("weapp-tw");
701
750
  function search(searchFrom = root) {
package/dist/index.d.cts CHANGED
@@ -3,6 +3,8 @@ import { FSWatcher } from 'fs-extra';
3
3
  import { UserDefinedOptions } from 'weapp-tailwindcss';
4
4
  import { WatchOptions } from 'gulp';
5
5
  import { Result } from 'postcss-load-config';
6
+ import { Options } from 'sass';
7
+ import { Settings } from 'gulp-typescript';
6
8
  import * as cosmiconfig from 'cosmiconfig';
7
9
 
8
10
  declare function createCli(): Command;
@@ -14,6 +16,18 @@ declare enum AssetType {
14
16
  Html = "html"
15
17
  }
16
18
 
19
+ interface GulpLessOptions {
20
+ modifyVars?: object | undefined;
21
+ paths?: string[] | undefined;
22
+ plugins?: any[] | undefined;
23
+ relativeUrls?: boolean | undefined;
24
+ }
25
+ interface GulpSassOptions extends Options<'sync'> {
26
+ errLogToConsole?: boolean | undefined;
27
+ onSuccess?: ((css: string) => any) | undefined;
28
+ onError?: ((err: Error) => any) | undefined;
29
+ sync?: boolean | undefined;
30
+ }
17
31
  interface BuildOptions {
18
32
  weappTailwindcssOptions: UserDefinedOptions;
19
33
  outDir: string;
@@ -29,16 +43,24 @@ interface BuildOptions {
29
43
  json?: string[];
30
44
  };
31
45
  postcssOptions?: Partial<Omit<Result, 'file'>>;
46
+ preprocessorOptions?: {
47
+ sass?: boolean | GulpSassOptions;
48
+ less?: boolean | GulpLessOptions;
49
+ };
32
50
  watchOptions: WatchOptions;
51
+ typescriptOptions: boolean | {
52
+ settings?: Settings;
53
+ tsConfigFileName?: string;
54
+ };
33
55
  }
34
56
  type UserConfig = Partial<BuildOptions>;
35
57
 
36
- declare function createBuilder(options?: Partial<BuildOptions>): {
58
+ declare function createBuilder(options?: Partial<BuildOptions>): Promise<{
37
59
  watcher: FSWatcher | undefined;
38
60
  build(): Promise<any>;
39
61
  watch(): any;
40
62
  globsSet: Set<string>;
41
- };
63
+ }>;
42
64
  declare function build(options?: Partial<BuildOptions>): Promise<{
43
65
  watcher: FSWatcher | undefined;
44
66
  build(): Promise<any>;