I'm relatively new to Webpack and I am facing an issue with my ProvidePlugin configuration not working as intended.
Here is the code snippet from my file:
App.js
var App = function() {
getSomething: function(size) {}
}();
module.exports = App;
I want to make sure that the 'App' variable is accessible globally, as it is being used in other files like this:
Layout.js
var Layout = function () {
App.getSomething('md');
}();
webpack.config.js
In my webpack.config.js file, the following line is included:
new webpack.ProvidePlugin({ App: 'app' })
Below is how I define my entry:
entry: {
'app': './angularApp/metronicapp.ts',
}
metronicapp.ts
app
represents myapp.js
as shown above.Upon checking the browser console, I encountered the error message:
Cannot find module "app"
When compiling webpack in the terminal, the error states:
Module not found: Error: Can't resolve 'app'
I am trying to identify what could be causing this issue. Is there something wrong with my app.js code structure? Why is the
App
variable still not globally available?