【问题标题】:Can I live reload styles, templates, and variables with Aglio?我可以使用 Aglio 实时重新加载样式、模板和变量吗?
【发布时间】:2016-10-13 15:06:10
【问题描述】:

我无法使用 Aglio 的 --server 选项或 gulp 搭配 connectlivereload 选项和 gulp-aglio 插件实时重新加载 LESS 和 Jade 文件。

这是因为缓存吗?还是connect 的实时重载能力受到限制?

使我的更改呈现的唯一方法是按 ctrl-C 并再次运行 gulp。

这是我的 gulpfile.js:

var 
    gulp = require('gulp'),  
    aglio = require('gulp-aglio'),
    connect = require('gulp-connect'),
    plumber = require('gulp-plumber'),
    watch = require('gulp-watch')
;

gulp.task('docs', function(){  
    gulp
        .src('docs/index.apib')
        .pipe(plumber())
        .pipe(aglio({
            themeTemplate: 'docs/templates/triple.jade', 
            themeStyle: 'docs/styles/layout-default.less', 
            themeVariables: 'docs/styles/variables-default.less', 
            themeFullWidth: true
        }))
        .pipe(gulp.dest('docs'))
    ;
});

gulp.task('server', function(){  
    connect.server({
        livereload: true,
        root: ['docs']
    });
});

gulp.task('livereload', ['docs'], function(){  
    gulp
        .src(['docs/*.apib'])
        .pipe(plumber())
        .pipe(connect.reload())
    ;
});

gulp.task('watch', function() {  
    gulp.watch(['docs/*.apib', 'docs/*.md', 'docs/styles/*.less', 'docs/templates/*.jade'], ['docs', 'livereload']);
})

gulp.task('default', ['docs', 'server', 'livereload', 'watch']);
gulp.task('build', ['docs']);  

【问题讨论】:

    标签: javascript gulp livereload apiblueprint aglio


    【解决方案1】:

    目前这是不可能的。 livereload 功能仅用于重新加载输入 API 蓝图文件。所有的主题文件都被缓存,因此它们只被加载一次。

    问题:您对此功能的用例是什么?

    【讨论】:

    • 感谢您的回复。得到这个问题的“风滚草徽章”哈哈。答:我想快速为 Aglio 开发一个自定义模板。
    • 知道这一点很有用。目前 livereload 是面向 API 编写者而不是主题编写者,所以每次你想看到你所做的任何更新时都必须重新启动 Aglio。老实说,我在处理主题/样式/布局/等时遇到了同样的问题,但还不足以保证重新加载它们。
    猜你喜欢
    • 2019-10-29
    • 2012-06-01
    • 1970-01-01
    • 2012-07-20
    • 2017-08-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-06-22
    相关资源
    最近更新 更多