I'm using webpack, angular 1.x and have the following code
import angular from 'angular';
which works good, but the problem is that included file is too big (angularjs - 1.15mb). It will be better of course to use minified version of angularjs, but when I change code to
import angular from 'angular/angular.min.js';
it doesn't work properly, I mean it seems like angular.min.js
doesn't export appropriate angular
object.
What's the right way to use minified version of library?
I've found github issue regarding the problem, it's good idea to use exports-loader. My solution is:
webpack.config.js
...
// Add alias, so webpack looks for minified version of angular
resolve: {
alias: {
angular: "angular/angular.min.js"
}
}
...
// Add exports loader for angular
modules: {
loaders: [
{
test: /angular\.min\.js$/,
loader: 'exports?angular'
}
]
}
After this configuration we can easily import minified version of angular using the following command
let angular = require('angular');
// or es6 version
import angular from 'angular';