Reputation: 640
I'm migrating a RequireJS project to Webpack and can't find a Webpack analog to domReady
.
In RequireJS, I require a null module with the domReady loader plugin, which marks itself as loaded once it receives the DOMContentLoaded event.
require(['dep1', 'dep2', 'domReady!'], function(){
// This code is only executed AFTER DOMContentLoaded
});
In Webpack, I've seen people map this to the node package requirejs-domready
, but neither package seems to function as a Webpack loader:
module.exports = {
resolveLoader: {
alias: {
'domReady': 'requirejs-domready'
}
},
}
ERROR in ./node_modules/requirejs-domready/domReady.js
Module build failed (from ./node_modules/requirejs-domready/domReady.js):
ReferenceError: define is not defined
Is there anything similar available in Webpack or a way to configure this module as a Webpack loader?
Upvotes: 2
Views: 229