Skip to content

Commit

Permalink
use HMR if available, no debug option required (#57)
Browse files Browse the repository at this point in the history
  • Loading branch information
tevcef authored and koistya committed Sep 12, 2016
1 parent f2a4d80 commit f97ac75
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions src/index.js
Expand Up @@ -17,7 +17,7 @@ module.exports.pitch = function pitch(remainingRequest) {
}

const insertCssPath = path.join(__dirname, './insertCss.js');
let output = `
return `
var content = require(${stringifyRequest(this, `!!${remainingRequest}`)});
var insertCss = require(${stringifyRequest(this, `!${insertCssPath}`)});
Expand All @@ -28,9 +28,7 @@ module.exports.pitch = function pitch(remainingRequest) {
module.exports = content.locals || {};
module.exports._getCss = function() { return content.toString(); };
module.exports._insertCss = function(options) { return insertCss(content, options) };
`;

output += this.debug ? `
// Hot Module Replacement
// https://webpack.github.io/docs/hot-module-replacement
// Only activated in browser context
Expand All @@ -47,7 +45,5 @@ module.exports.pitch = function pitch(remainingRequest) {
});
module.hot.dispose(function() { removeCss(); });
}
` : '';

return output;
`;
};

0 comments on commit f97ac75

Please sign in to comment.