From 96ab2aa98937b5f41eccbc63e14fce1d557cbfe4 Mon Sep 17 00:00:00 2001 From: gallenhu Date: Fri, 1 Jul 2016 16:55:35 +0800 Subject: [PATCH] Fixbug for running in Node express Update readme Update package.json --- README.md | 69 +++------------------------------------------------- index.js | 4 ++- package.json | 10 ++++---- 3 files changed, 11 insertions(+), 72 deletions(-) diff --git a/README.md b/README.md index 730ee77..f3d14f3 100644 --- a/README.md +++ b/README.md @@ -1,67 +1,4 @@ -# Open Browser Webpack Plugin -Opens a new browser tab when Webpack loads. Very useful if you're lazy and don't want to force yourself to open a new tab when Webpack is ready to play! +# Open Browser Webpack Express Plugin +Base on [Open Browser Webpack Plugin](https://github.com/baldore/open-browser-webpack-plugin). -## Usage - -Simply require the plugin and add it in the **plugins** section: - -```javascript -var OpenBrowserPlugin = require('open-browser-webpack-plugin'); - -module.exports = { - entry: path.resolve(__dirname, 'lib/entry.js'), - output: { - path: __dirname + "/bundle/", - filename: "bundle.js" - }, - plugins: [ - new OpenBrowserPlugin({ url: 'http://localhost:3000' }) - ] -}; -``` - -## Options - -#### url - -Type: `String`
-Default: `http://localhost:8080` - -Url to open when Webpack is ready. Needs to have the prefix `http://` or `https://` in order to open the browser. - -#### browser - -Type: `String`
-Optional - -Browser to open. By default, it will try to open the browser set by default in your system. - -#### ignoreErrors - -Type: `String`
-Default: `False`
-Optional - -By default this plugin only opens the browser if there's no Webpack errors. Setting ignoreErrors to true will open a new tab no matter the compilation errors. - -## Change Log - -### 0.0.2 - 2015-12-26 -#### Added -- ignoreErrors option (Thanks to @zhura). -- Changelog. -- Documentation for options. - -#### Removed -- DEFAULT_BROWSER constant. - -### 0.0.1 - 2015-09-12 -- First release. - -## TODO - -- [ ] Add tests. - -## License - -MIT License. +Adapt Node Express Proxy by Opening Browser Async. diff --git a/index.js b/index.js index 8b14c17..ac265ce 100644 --- a/index.js +++ b/index.js @@ -40,7 +40,9 @@ OpenBrowserPlugin.prototype.apply = function(compiler) { compiler.plugin('done', function doneCallback(stats) { if (isWatching && (!stats.hasErrors() || ignoreErrors)) { - removeFromArray(stats.compilation.compiler._plugins['done'], doneCallback); + setTimeout(function () { + removeFromArray(stats.compilation.compiler._plugins['done'], doneCallback); + }, 0); open(url, browser, function(err) { if (err) throw err; }); diff --git a/package.json b/package.json index ca8014a..2c1d367 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { - "name": "open-browser-webpack-plugin", - "version": "0.0.2", + "name": "open-browser-webpack-express-plugin", + "version": "0.0.3", "description": "Opens the browser when Webpack is ready serving your files.", "main": "index.js", "scripts": { @@ -9,7 +9,7 @@ }, "repository": { "type": "git", - "url": "git+https://github.com/baldore/webpack-open-plugin.git" + "url": "git+https://github.com/GallenHu/open-browser-webpack-plugin.git" }, "keywords": [ "webpack", @@ -23,9 +23,9 @@ "author": "Camilo Orrego", "license": "MIT", "bugs": { - "url": "https://github.com/baldore/webpack-open-plugin/issues" + "url": "https://github.com/GallenHu/open-browser-webpack-plugin/issues" }, - "homepage": "https://github.com/baldore/webpack-open-plugin#readme", + "homepage": "https://github.com/GallenHu/open-browser-webpack-plugin#readme", "dependencies": { "open": "0.0.5" },