gulp-tmod icon indicating copy to clipboard operation
gulp-tmod copied to clipboard

不生效,哪里错了?

Open liyatang opened this issue 10 years ago • 6 comments
trafficstars

你好,使用 gulp-tmod 中遇到了点问题,求指导。

我这样用是ok的

gulp.task('mobile-tmod', function () {
    return gulp.src(['./mobile/tpl/*.html', './mobile/tpl/**/*.html']).
        pipe(tmodjs({
            base: './mobile/tpl',
            output: './mobile/tpl/build'
        }));
});

image

问题来了...

然后我要使用watch。 完全按照readme的使用哦。

gulp.task('mobile-tmod-watch', function () {
    return gulp.src(['./mobile/tpl/*.html', './mobile/tpl/**/*.html']).
        pipe(watch(function (files) {
            files.pipe(tmodjs({
                base: './mobile/tpl',
                combo: true,
                output: './mobile/tpl/build'
            }));
        }));
});

然后就报bug了

image

从提示上来看是gulp-watch 的参数问题,于是修正如下(给watch加了第一个参数)。

gulp.task('mobile-tmod-watch', function () {
    return gulp.src(['./mobile/tpl/*.html', './mobile/tpl/**/*.html']).
        pipe(watch(['./mobile/tpl/*.html', './mobile/tpl/**/*.html'], function (files) {
            files.pipe(tmodjs({
                base: './mobile/tpl',
                combo: true,
                output: './mobile/tpl/build'
            }));
        }));
});

还是有错误

image

然后我看了官网(https://github.com/floatdrop/gulp-watch)gulp-watch的用法,改为

gulp.task('mobile-tmod-watch', function () {
    return gulp.src(['./mobile/tpl/*.html', './mobile/tpl/**/*.html']).
        pipe(watch(['./mobile/tpl/*.html', './mobile/tpl/**/*.html'])).
        pipe(plugins.tmod({
            base: './mobile/tpl',
            output: './mobile/tpl/build'
        }));
});

没有报错

image

可是我修改模板,并没有执行编译

求助,我应该怎么写

liyatang avatar Mar 04 '15 10:03 liyatang

问题解决没?

lichunqiang avatar Apr 27 '15 08:04 lichunqiang

多谢关注。问题还没有解决,求指导。 我Q 531059158

liyatang avatar Apr 28 '15 23:04 liyatang

同样的问题,现在只好用 tmod 的命令行来监视并 build

thethreeonee avatar Jun 11 '15 06:06 thethreeonee

不好意思,工作原因不在使用tmod了,对于目前碰到的问题暂时没有精力去解决,如果大家能解决问题可以提pr。

抱歉!

lichunqiang avatar Jun 11 '15 06:06 lichunqiang

我也遇到这个问题,目前写的是这样子:

gulp.watch([path.join(tpl.src, '*/.html')]).on('change', function (event) {
if (event.type === 'changed') { console.log("动态编译模板...",event.path); gulp.src(event.path) .pipe($.tmod({ base: tpl.src, combo: true, cache:false, type:"cmd", output: tpl.dist })) } });

改动之后有监视到变化 也有执行操作,但是编译就是失败了。。。我也没看出来问题到底在哪儿

que01 avatar Sep 08 '15 08:09 que01

我看了下tmod的源码 它自己带有watch功能 可看https://github.com/aui/tmodjs/blob/master/bin/tmod#L207 不明白作者为啥没加 我把这行代码加到作者的gulp插件里边去(注意加到生成的tmod实例后面) 亲测可用 不过这样就直接开启了实时监控的功能了 可以在option里加一个参数用来控制是否开启

dashixiong1990 avatar Sep 22 '15 02:09 dashixiong1990