• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

juanfran/gulp-jade-inheritance: Gulp plugin to rebuild jade files and other file ...

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称(OpenSource Name):

juanfran/gulp-jade-inheritance

开源软件地址(OpenSource Url):

https://github.com/juanfran/gulp-jade-inheritance

开源编程语言(OpenSource Language):

JavaScript 100.0%

开源软件介绍(OpenSource Introduction):

#gulp-jade-inheritance Build Status

Rebuild a jade file with other files that have extended or included those file

Inspired by jade-inheritance

Install

npm install gulp-jade-inheritance --save-dev

Usage

gulpfile.js

var jadeInheritance = require('gulp-jade-inheritance');
var jade = require('gulp-jade');

gulp.task('jade-inheritance', function() {
  gulp.src('/jade/example.jade')
    .pipe(jadeInheritance({basedir: '/jade/'}))
    .pipe(jade());
});

In this example jade compile example.jade and all other files that have been extended or included example.jade. The plugin searches for those dependencies in the basedir directory.

Only process changed files

You can use gulp-jade-inheritance with gulp-changed and gulp-cached to only process the files that have changed. This also prevent partials from being processed separately by marking them with an underscore before their name.

'use strict';
var gulp = require('gulp');
var jadeInheritance = require('gulp-jade-inheritance');
var jade = require('gulp-jade');
var changed = require('gulp-changed');
var cached = require('gulp-cached');
var gulpif = require('gulp-if');
var filter = require('gulp-filter');

gulp.task('jade', function() {
    return gulp.src('app/**/*.jade')

        //only pass unchanged *main* files and *all* the partials
        .pipe(changed('dist', {extension: '.html'}))

        //filter out unchanged partials, but it only works when watching
        .pipe(gulpif(global.isWatching, cached('jade')))

        //find files that depend on the files that have changed
        .pipe(jadeInheritance({basedir: 'app'}))

        //filter out partials (folders and files starting with "_" )
        .pipe(filter(function (file) {
            return !/\/_/.test(file.path) && !/^_/.test(file.relative);
        }))

        //process jade templates
        .pipe(jade())

        //save all the files
        .pipe(gulp.dest('dist'));
});
gulp.task('setWatch', function() {
    global.isWatching = true;
});
gulp.task('watch', ['setWatch', 'jade'], function() {
    //your watch functions...
});

If you want to prevent partials from being processed, mark them with an underscore before their name or their parent folder's name. Example structure:

/app/index.jade
/app/_header.jade
/app/_partials/article.jade
/dist/

To install all that's need for it:

npm install gulp-jade-inheritance gulp-jade gulp-changed gulp-cached gulp-if gulp-filter --save-dev

jade >= 1.11

if your using jade 1.11 add "jade": "^1.11.0" to your package.json to overwrite the jade-inheritance version. Issue




鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Hiswe/gulp-svg-symbols: Convert svg files to symbols发布时间:2022-06-21
下一篇:
Sponsor @shannonmoeller on GitHub Sponsors · GitHub发布时间:2022-06-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap