webpack-hot-middleware
Advanced tools
Comparing version 2.20.0 to 2.21.0
@@ -23,5 +23,2 @@ /*eslint-env browser*/ | ||
}; | ||
for (var key in styles) { | ||
clientOverlay.style[key] = styles[key]; | ||
} | ||
@@ -41,3 +38,2 @@ var ansiHTML = require('ansi-html'); | ||
}; | ||
ansiHTML.setColors(colors); | ||
@@ -47,3 +43,2 @@ var Entities = require('html-entities').AllHtmlEntities; | ||
exports.showProblems = | ||
function showProblems(type, lines) { | ||
@@ -61,5 +56,4 @@ clientOverlay.innerHTML = ''; | ||
} | ||
}; | ||
} | ||
exports.clear = | ||
function clear() { | ||
@@ -69,10 +63,9 @@ if (document.body && clientOverlay.parentNode) { | ||
} | ||
}; | ||
} | ||
var problemColors = { | ||
errors: colors.red, | ||
warnings: colors.yellow | ||
}; | ||
function problemType (type) { | ||
var problemColors = { | ||
errors: colors.red, | ||
warnings: colors.yellow | ||
}; | ||
var color = problemColors[type] || colors.red; | ||
@@ -85,1 +78,26 @@ return ( | ||
} | ||
module.exports = function(options) { | ||
for (var color in options.overlayColors) { | ||
if (color in colors) { | ||
colors[color] = options.overlayColors[color]; | ||
} | ||
ansiHTML.setColors(colors); | ||
} | ||
for (var style in options.overlayStyles) { | ||
styles[style] = options.overlayStyles[style]; | ||
} | ||
for (var key in styles) { | ||
clientOverlay.style[key] = styles[key]; | ||
} | ||
return { | ||
showProblems: showProblems, | ||
clear: clear | ||
} | ||
}; | ||
module.exports.clear = clear; | ||
module.exports.showProblems = showProblems; |
@@ -12,3 +12,5 @@ /*eslint-env browser*/ | ||
name: '', | ||
autoConnect: true | ||
autoConnect: true, | ||
overlayStyles: {}, | ||
ansiColors: {} | ||
}; | ||
@@ -61,2 +63,5 @@ if (__resourceQuery) { | ||
} | ||
if (overrides.ansiColors) options.ansiColors = JSON.parse(overrides.ansiColors); | ||
if (overrides.overlayStyles) options.overlayStyles = JSON.parse(overrides.overlayStyles); | ||
} | ||
@@ -155,3 +160,6 @@ | ||
if (typeof document !== 'undefined' && options.overlay) { | ||
overlay = require('./client-overlay'); | ||
overlay = require('./client-overlay')({ | ||
ansiColors: options.ansiColors, | ||
overlayStyles: options.overlayStyles | ||
}); | ||
} | ||
@@ -158,0 +166,0 @@ |
{ | ||
"name": "webpack-hot-middleware", | ||
"version": "2.20.0", | ||
"version": "2.21.0", | ||
"description": "Webpack hot reloading you can attach to your own server", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -94,3 +94,18 @@ # Webpack Hot Middleware | ||
* **autoConnect** - Set to `false` to use to prevent a connection being automatically opened from the client to the webpack back-end - ideal if you need to modify the options using the `setOptionsAndConnect` function | ||
* **ansiColors** - An object to customize the client overlay colors as mentioned in the [ansi-html](https://github.com/Tjatse/ansi-html/blob/99ec49e431c70af6275b3c4e00c7be34be51753c/README.md#set-colors) package. | ||
* **overlaySyles** - An object to let you override or add new inline styles to the client overlay div. | ||
> Note: | ||
> Since the `ansiColors` and `overlaySyles` options are passed via query string, you'll need to uri encode your stringified options like below: | ||
```js | ||
var ansiColors = { | ||
red: '00FF00' // note the lack of "#" | ||
}; | ||
var overlayStyles = { | ||
color: '#FF0000' // note the inclusion of "#" (these options would be the equivalent of div.style[option] = value) | ||
}; | ||
var hotMiddlewareScript = 'webpack-hot-middleware/client?path=/__webpack_hmr&timeout=20000&reload=true&ansiColors=' + encodeURIComponent(JSON.stringify(ansiColors)) + '&overlayStyles=' + encodeURIComponent(JSON.stringify(overlayStyles)); | ||
``` | ||
#### Middleware | ||
@@ -97,0 +112,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
198
27798
7
576