Webpack ProvidePlugin/vendor bundle: angular.module is not a function Webpack ProvidePlugin/vendor bundle: angular.module is not a function angularjs angularjs

Webpack ProvidePlugin/vendor bundle: angular.module is not a function


To answer the question in the headline of the original post, Angular 1 is not working nicely with webpack without a shim (see https://github.com/webpack/webpack/issues/2049). Try this webpack loader config:

module: {    loaders: [        /*         * Necessary to be able to use angular 1 with webpack as explained in https://github.com/webpack/webpack/issues/2049         */        {            test: require.resolve('angular'),            loader: 'exports?window.angular'        },    ]},plugins: [    new webpack.ProvidePlugin({        'angular': 'angular',    }),],

This should initialize the angular object properly instead of the default action of setting it to an empty object (which does not have a property named module).


Following should move all the scripts not in src folder to vendor chunk.

const path = require('path');const projectRoot = path.resolve('./');      new webpack.optimize.CommonsChunkPlugin({        name: 'vendor',        minChunks: (module) => module.resource && module.resource.indexOf(path.join(projectRoot, 'src')) === -1,      }),