javascript - gulp useref remove files from pipeline -
is there way not output gulp.src file? goal bundle javascript , output .js only, not html.
in base.html following blocks used bundle javascript gulp-useref:
<!-- build:js app.core.js --> <script src="{{ static_url }}etherflex/js/vendor/conditionizr_4.5.1.js"></script> <script src="{{ static_url }}etherflex/js/app/conditionizr.detects.js"></script> <script src="{{ static_url }}etherflex/js/app/conditionizr.config.js"></script> <script src="{{ static_url }}etherflex/js/vendor/mootools-core_1.4.5.js"></script> <!-- endbuild --> the gulp task
var gulp = require('gulp'); var notify = require('gulp-notify'); var changed = require('gulp-changed'); var plumber = require('gulp-plumber'); var uglify = require('gulp-uglify'); var rename = require('gulp-rename'); var gzip = require('gulp-gzip'); var useref = require('gulp-useref'); var gulpif = require('gulp-if'); module.exports = function (path) { return gulp.src('templates/**/*.html') .pipe(plumber({errorhandler: notify.onerror("error: <%= error.message %>")})) .pipe(useref({ searchpath: path.source, transformpath: function(filepath) { return filepath.replace('{{ static_url }}/','') } })) .pipe(changed(path.build + 'js')) .pipe(gulpif('*.js', uglify())) .pipe(rename({ suffix: ".min", })) .pipe(gulp.dest(path.build + 'js')) .pipe(notify("javascript concatenated, minified , gzip compressed: <%= file.relative %>")) .pipe(gzip()) .pipe(gulp.dest(path.build + 'js')); }; the goal read block comments in base.html , output bundled javascript app.core.js.
any suggestions?
to expand on comment, can use gulp-if filter stream gulp.dest.
.pipe(gulpif('*.js', gulp.dest(path.build + 'js')))
Comments
Post a Comment