Skip to content

Instantly share code, notes, and snippets.

@thesabbir
Last active August 20, 2016 20:42
Show Gist options
  • Save thesabbir/64026e2bcc05d45c461312604446430e to your computer and use it in GitHub Desktop.
Save thesabbir/64026e2bcc05d45c461312604446430e to your computer and use it in GitHub Desktop.
Webpack opener plugin
const opener = require('opener');
const { devServerUrl } = require('./config');
const removeCallback = require('lodash/pull');
function OpenerPlugin() {
}
OpenerPlugin.prototype.apply = (compiler) => {
compiler.plugin('done', function openerCallback(stats) {
/*eslint no-console:0*/
if (!stats.hasErrors()) {
removeCallback(stats.compilation.compiler._plugins.done, openerCallback);
opener(devServerUrl);
}
});
};
module.exports = OpenerPlugin;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment