在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):juanfran/gulp-jade-inheritance开源软件地址(OpenSource Url):https://github.com/juanfran/gulp-jade-inheritance开源编程语言(OpenSource Language):JavaScript 100.0%开源软件介绍(OpenSource Introduction):
Inspired by jade-inheritance Installnpm install gulp-jade-inheritance --save-dev Usage
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 Only process changed filesYou can use '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:
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.11if your using jade 1.11 add |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论