javascript - gulp-rev generating new file name for same code base -
working on codebase has used yeoman angular generator (1.4.x).
gulp-rev
getting used , it's generating new file (hash) name every single time same code base, how can keep same file hash?
here's main task that's building (i suppose),
gulp.task('html', ['inject', 'partials'], function () { var partialsinjectfile = gulp.src(path.join(conf.paths.tmp, '/partials/templatecachehtml.js'), { read: false }); var partialsinjectoptions = { starttag: '<!-- inject:partials -->', ignorepath: path.join(conf.paths.tmp, '/partials'), addrootslash: false }; var htmlfilter = $.filter('*.html', { restore: true }); var jsfilter = $.filter('**/*.js', { restore: true }); var cssfilter = $.filter('**/*.css', { restore: true }); return gulp.src(path.join(conf.paths.tmp, '/serve/*.html')) .pipe($.inject(partialsinjectfile, partialsinjectoptions)) .pipe($.useref()) .pipe(jsfilter) .pipe($.sourcemaps.init()) .pipe($.ngannotate()) .pipe($.uglify({ preservecomments: $.uglifysavelicense })).on('error', conf.errorhandler('uglify')) .pipe($.rev()) .pipe($.sourcemaps.write('maps')) .pipe(jsfilter.restore) .pipe(cssfilter) // .pipe($.sourcemaps.init()) .pipe($.replace('../../bower_components/bootstrap-sass/assets/fonts/bootstrap/', '../fonts/')) .pipe($.cssnano()) .pipe($.rev()) // .pipe($.sourcemaps.write('maps')) .pipe(cssfilter.restore) .pipe($.revreplace()) .pipe(htmlfilter) .pipe($.htmlmin({ removeemptyattributes: true, removeattributequotes: true, collapsebooleanattributes: true, collapsewhitespace: true })) .pipe(htmlfilter.restore) .pipe(gulp.dest(path.join(conf.paths.dist, '/'))) .pipe($.size({ title: path.join(conf.paths.dist, '/'), showfiles: true })); });
styles task
'use strict'; var path = require('path'); var gulp = require('gulp'); var conf = require('./conf'); var browsersync = require('browser-sync'); var $ = require('gulp-load-plugins')(); var wiredep = require('wiredep').stream; var _ = require('lodash'); gulp.task('styles-reload', ['styles'], function() { return buildstyles() .pipe(browsersync.stream()); }); gulp.task('styles', function() { return buildstyles(); }); var buildstyles = function() { var sassoptions = { outputstyle: 'expanded', precision: 10 }; var injectfiles = gulp.src([ path.join(conf.paths.src, '/app/**/*.scss'), path.join('!' + conf.paths.src, '/app/app.scss') ], { read: false }); var injectoptions = { transform: function(filepath) { filepath = filepath.replace(conf.paths.src + '/app/', ''); return '@import "' + filepath + '";'; }, starttag: '// injector', endtag: '// endinjector', addrootslash: false }; return gulp.src([ path.join(conf.paths.src, '/app/app.scss') ]) .pipe($.inject(injectfiles, injectoptions)) .pipe(wiredep(_.extend({}, conf.wiredep))) .pipe($.sourcemaps.init()) .pipe($.sass(sassoptions)).on('error', conf.errorhandler('sass')) .pipe($.autoprefixer()).on('error', conf.errorhandler('autoprefixer')) .pipe($.sourcemaps.write()) .pipe(gulp.dest(path.join(conf.paths.tmp, '/serve/app/'))); };
scripts task
'use strict'; var path = require('path'); var gulp = require('gulp'); var conf = require('./conf'); var browsersync = require('browser-sync'); var $ = require('gulp-load-plugins')(); gulp.task('scripts-reload', function() { return buildscripts() .pipe(browsersync.stream()); }); gulp.task('scripts', function() { return buildscripts(); }); function buildscripts() { return gulp.src(path.join(conf.paths.src, '/app/**/*.js')) .pipe($.eslint()) .pipe($.eslint.format()) .pipe($.size()) };
found piece on gulp-rev github page but, i'm not @ gulp, don't know change , in task here.
the stated purpose of gulp-rev this:
static asset revisioning appending content hash filenames unicorn.css → unicorn-d41d8cd98f.css
the idea able cache these static files, still deliver latest code user. if didn't want revision assets, can take out pipeline:
return gulp.src(path.join(conf.paths.tmp, '/serve/*.html')) .pipe($.inject(partialsinjectfile, partialsinjectoptions)) .pipe($.useref()) .pipe(jsfilter) .pipe($.sourcemaps.init()) .pipe($.ngannotate()) .pipe($.uglify({ preservecomments: $.uglifysavelicense })).on('error', conf.errorhandler('uglify')) .pipe($.sourcemaps.write('maps')) .pipe(jsfilter.restore) .pipe(cssfilter) // .pipe($.sourcemaps.init()) .pipe($.replace('../../bower_components/bootstrap-sass/assets/fonts/bootstrap/', '../fonts/')) .pipe($.cssnano()) // .pipe($.sourcemaps.write('maps')) .pipe(cssfilter.restore) .pipe(htmlfilter) .pipe($.htmlmin({ removeemptyattributes: true, removeattributequotes: true, collapsebooleanattributes: true, collapsewhitespace: true })) .pipe(htmlfilter.restore) .pipe(gulp.dest(path.join(conf.paths.dist, '/'))) .pipe($.size({ title: path.join(conf.paths.dist, '/'), showfiles: true }));
Comments
Post a Comment