I am beginner for learn angular and webpack, I using node command prompt to run angular in webpack, I am just given angular.min.js link in app.js file but the bundle.js not accept the anguar.module(), it is says angular.module is not a function, please help me to achieve this
var angular = require('../node_modules/angular/angular.js');
var ngModule = angular.module('app',[]);
console.log(ngModule);
WebPack will load modules directly from node_modules without having to be configured to do so. You just need to add them as entry points in the config.
webpack.config.js
entry: {
vendor: ['angular'],
app: './src/app.js'
}
You can add other modules like lodash or jquery this way as well.
Now in your code you can use angular like this
import angular from 'angular';
export default angular.module('app',[]);
You can then import the module in other JS files like this.
import app from './app.js';
app.directive('myWidget',.....);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With