axios-axios/webpack.config.js
Paweł Szymański e52cd3ac64
Add globalObject: 'this' to webpack config (#3176)
This should solve the issue of undefined `this` when importing from an ES6 module.
I've put steps to reproduce in [this comment](https://github.com/axios/axios/issues/1861#issuecomment-669832435).

Co-authored-by: Jay <jasonsaayman@gmail.com>
2021-09-16 21:08:40 +02:00

31 lines
685 B
JavaScript

const TerserPlugin = require('terser-webpack-plugin');
var webpack = require('webpack');
var config = {};
function generateConfig(name) {
var compress = name.indexOf('min') > -1;
var config = {
entry: './index.js',
output: {
path: __dirname + '/dist/',
filename: name + '.js',
sourceMapFilename: name + '.map',
library: 'axios',
libraryTarget: 'umd',
globalObject: 'this'
},
node: {
process: false
},
devtool: 'source-map',
mode: compress ? 'production' : 'development'
};
return config;
}
['axios', 'axios.min'].forEach(function (key) {
config[key] = generateConfig(key);
});
module.exports = config;