Skip to content

Instantly share code, notes, and snippets.

@ahmadajmi
Last active September 13, 2017 22:31
Show Gist options
  • Save ahmadajmi/af66ab4cd84d0ceca527be07700a6f51 to your computer and use it in GitHub Desktop.
Save ahmadajmi/af66ab4cd84d0ceca527be07700a6f51 to your computer and use it in GitHub Desktop.
PhantomCSS example with Gulp
npm install gulp-phantomcss --save

gulpfile.js

var phantomcss      = require('gulp-phantomcss');

// PhantomCSS
gulp.task('phantomcss-desktop', function () {
  return gulp.src('./testsuite.js')
  .pipe(phantomcss({
    screenshots: 'desktop',
    viewportSize: [1000, 1100]
  }));
});

gulp.task('phantomcss-mobile', function () {
  return gulp.src('./testsuite.js')
  .pipe(phantomcss({
    screenshots: 'mobile',
    viewportSize: [320, 600]
  }));
});

gulp.task('phantomcss', function () {
  gulp.start('phantomcss-desktop', 'phantomcss-mobile');
});

testsuite.js

casper.
  start('http://localhost:2368/').
  then(function() {
    phantomcss.screenshot('.site-header', 'site-header');
  });

casper.run();
@ahmadajmi
Copy link
Author

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