Created
September 9, 2014 21:08
-
-
Save appsforartists/55b65f291aeda8174b80 to your computer and use it in GitHub Desktop.
Hiding server-side dependencies from Webpack
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var jsdom; // populated later if contextIsBrowser fails | |
var utilities = { | |
"domify": function (node) { | |
if (!node["getElementsByTagName"]) { | |
node = jsdom(node); | |
} | |
return node; | |
}, | |
"contextIsBrowser": function () { | |
var getGlobalScope = function () { | |
return this; | |
}; | |
return getGlobalScope().hasOwnProperty('window'); | |
} | |
}; | |
if (!utilities.contextIsBrowser()) { | |
jsdom = require('jsdom').jsdom; | |
} | |
module.exports = utilities; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//… | |
"plugins": [ | |
new Webpack.IgnorePlugin(/jsdom/) | |
], | |
// … |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment