Skip to content

Instantly share code, notes, and snippets.

@Xhamps
Last active January 4, 2017 21:52
Show Gist options
  • Save Xhamps/bb74d7308954839a9148ea3728196f83 to your computer and use it in GitHub Desktop.
Save Xhamps/bb74d7308954839a9148ea3728196f83 to your computer and use it in GitHub Desktop.
var path = require("path");
var gulp = require("gulp");
var config = require("../project.config");
var runSequence = require('run-sequence');
gulp.task("default", false, () => {
gulp.tasks.help.fn();
});
gulp.task("build", "Copy assets, build CSS and JS.", ["clean"], (cb) => {
runSequence(
['build:html', 'build:css', 'copy'],
'rev:create',
'rev:replace',
cb
);
});
gulp.task("build-dev", "Build, but with unminified JS + sourcemaps.", ["clean"], () => {
gulp.run("build:html");
gulp.run("copy");
gulp.run("build:css");
gulp.run("build:js-dev");
}
);
gulp.task("watch", "Perform build-dev when sources change.", ["build-dev"], () => {
gulp.watch(path.join(config.srcFullPath, "**/*"), ["build-dev"]);
});
var fs = require('fs');
var path = require('path');
var gulp = require('gulp');
var rev = require('gulp-rev');
var revReplace = require('gulp-rev-replace');
var revDeleteOriginal = require('gulp-rev-delete-original');
var config = require('../../project.config');
gulp.task('rev:create', [], () => {
return Promise.all([
new Promise((resolve, reject) => {
gulp.src(path.join(config.destPathProperties, '**', '*.css'))
.pipe(rev())
.pipe(revDeleteOriginal())
.on('error', reject)
.pipe(gulp.dest(config.destPathProperties))
.pipe(rev.manifest())
.pipe(gulp.dest(config.destPathProperties))
.on('end', resolve);
}),
new Promise((resolve, reject) => {
gulp.src(path.join(config.destPathLaunch, '**', '*.css'))
.pipe(rev())
.pipe(revDeleteOriginal())
.on('error', reject)
.pipe(gulp.dest(config.destPathLaunch))
.pipe(rev.manifest())
.pipe(gulp.dest(config.destPathLaunch))
.on('end', resolve);
})
]);
});
gulp.task('rev:replace', [], () => {
gulp.src(path.join(config.destPathProperties, '**', '*.html'))
.pipe(revReplace({
manifest: gulp.src(path.join(config.destPathProperties,'rev-manifest.json'))
}))
.pipe(gulp.dest(config.destPathProperties));
});
@wbruno
Copy link

wbruno commented Jan 4, 2017

tenta assim:

var fs = require('fs');
var path = require("path");
var gulp = require("gulp");
var rev = require('gulp-rev');
var runSequence = require('run-sequence');
var revReplace = require('gulp-rev-replace');
var revDeleteOriginal = require('gulp-rev-delete-original');
var config = require("../project.config");


gulp.task("default", false, () => {
  return gulp.tasks.help.fn();
});

gulp.task("build", "Copy assets, build CSS and JS.", ["clean"], (cb) => {
  runSequence(
    ['build:html', 'build:css', 'copy'],
    'rev:replace',
    cb
  );
});

gulp.task("build-dev", "Build, but with unminified JS + sourcemaps.", ["clean"], () => {
    gulp.run("build:html");
    gulp.run("copy");
    gulp.run("build:css");
    gulp.run("build:js-dev");
  }
);

gulp.task('rev:create:property', () => {
  return gulp.src(path.join(config.destPathProperties, '**', '*.css'))
    .pipe(rev())
    .pipe(revDeleteOriginal())
    .on('error', reject)
    .pipe(gulp.dest(config.destPathProperties))
    .pipe(rev.manifest())
    .pipe(gulp.dest(config.destPathProperties))
    .on('end', resolve);
});

gulp.task('rev:create:launch', () => {
  return gulp.src(path.join(config.destPathLaunch, '**', '*.css'))
    .pipe(rev())
    .pipe(revDeleteOriginal())
    .on('error', reject)
    .pipe(gulp.dest(config.destPathLaunch))
    .pipe(rev.manifest())
    .pipe(gulp.dest(config.destPathLaunch))
    .on('end', resolve);
});

gulp.task('rev:replace', ['rev:create:launch', 'rev:create:property'], () => {
  return gulp.src(path.join(config.destPathProperties, '**', '*.html'))
    .pipe(revReplace({
      manifest: gulp.src(path.join(config.destPathProperties,'rev-manifest.json'))
    }))
    .pipe(gulp.dest(config.destPathProperties));
});

gulp.task("watch", "Perform build-dev when sources change.", ["build-dev"], () => {
  return gulp.watch(path.join(config.srcFullPath, "**/*"), ["build-dev"]);
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment