script.js
script.js copied to clipboard
consuming with webpack for node.js and isomorphic
Q. We're using script.js and webpack to bundle for both the browser and node.js. What is the best approach here to provide a fallback?
Current, as expected, I get this error (as expected) -
var doc = document
^
ReferenceError: document is not defined
Which is from this code -
})('$script', function () {
var doc = document
document and head variables declaration only need to be moved to the create() function (so improt/require works in server side)