2
0
mirror of https://github.com/tenrok/axios.git synced 2026-06-17 19:21:29 +03:00

Update Webpack + deps, remove now unnecessary polyfills (#2410)

* Update deps

 * handles webpack 1 -> 4 migration

* remove promise helpers from dev files

assume `Promise` is available, or polyfilled by
the consumer

* Remove isArray util. `isArray` has good coverage, even
   in IE9. So lets remove the custom polyfill.

 https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/isArray

also resolves a few lint issues

* Remove trim util

String.protoype.trim has good coverage (including IE9)

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/Trim

Also, the http adapter already uses the native method.
This commit is contained in:
Avindra Goolcharan
2019-10-21 14:56:29 -04:00
committed by Felipe Martins
parent 29da6b24db
commit 189b34c45a
13 changed files with 47 additions and 113 deletions
+18 -26
View File
@@ -1,12 +1,13 @@
var webpack = require('webpack');
var config = {};
const webpack = require('webpack');
const TerserPlugin = require('terser-webpack-plugin');
const config = {};
function generateConfig(name) {
var uglify = name.indexOf('min') > -1;
var config = {
return {
mode: 'production',
entry: './index.js',
output: {
path: 'dist/',
path: `${__dirname}/dist`,
filename: name + '.js',
sourceMapFilename: name + '.map',
library: 'axios',
@@ -15,30 +16,21 @@ function generateConfig(name) {
node: {
process: false
},
devtool: 'source-map'
devtool: 'source-map',
optimization: {
minimize: name.includes('min'),
minimizer: [
// config options documented at https://github.com/webpack-contrib/terser-webpack-plugin#terseroptions
new TerserPlugin({
sourceMap: true,
}),
],
},
};
config.plugins = [
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV)
})
];
if (uglify) {
config.plugins.push(
new webpack.optimize.UglifyJsPlugin({
compressor: {
warnings: false
}
})
);
}
return config;
}
['axios', 'axios.min'].forEach(function (key) {
config[key] = generateConfig(key);
['axios', 'axios.min'].forEach(outputScript => {
config[outputScript] = generateConfig(outputScript);
});
module.exports = config;