1 |
|
2 | 'use strict';
|
3 | var gulp = require('gulp');
|
4 | var extToGlob = require('../lib/ext-to-glob');
|
5 | var unlink = require('../lib/unlink');
|
6 | var compileWxml = require('../compiler/compress-wxml');
|
7 | var watchLog = require('../log/watch');
|
8 |
|
9 | var WXML_EXTS = ['wxml', 'html'];
|
10 |
|
11 |
|
12 |
|
13 |
|
14 | exports.build = function (config) {
|
15 | return function () {
|
16 | return compileWxml(config, extToGlob(config, WXML_EXTS));
|
17 | };
|
18 | }
|
19 |
|
20 |
|
21 |
|
22 | exports.watch = function (config) {
|
23 | return function (cb) {
|
24 | var glob = extToGlob(config, WXML_EXTS);
|
25 | watchLog('wxml', glob)
|
26 | gulp.watch(glob)
|
27 | .on('change', function (file) { return compileWxml(config, file); })
|
28 | .on('add', function (file) { return compileWxml(config, file); })
|
29 | .on('unlink', unlink(config.src, config.dist, '.wxml'));
|
30 | cb && cb();
|
31 |
|
32 | }
|
33 | } |
\ | No newline at end of file |