forked from axios/axios
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e49237c
commit 2abe8eb
Showing
1 changed file
with
34 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,60 +1,41 @@ | ||
var webpack = require('webpack'); | ||
|
||
var EXTERNAL_PROMISE = '{Promise: Promise}'; | ||
var config = {}; | ||
var base = { | ||
entry: './index.js', | ||
output: { | ||
path: 'dist/', | ||
filename: 'axios.js', | ||
sourceMapFilename: 'axios.map', | ||
library: 'axios' | ||
}, | ||
externals: [ | ||
{ | ||
'./adapters/http': 'var undefined' | ||
} | ||
], | ||
devtool: 'source-map' | ||
}; | ||
|
||
['amd', 'global', 'amd-standalone', 'global-standalone'].forEach(function (key) { | ||
config[key] = JSON.parse(JSON.stringify(base)); | ||
config[key + '-min'] = JSON.parse(JSON.stringify(base)); | ||
|
||
config[key + '-min'].plugins = [ | ||
new webpack.optimize.UglifyJsPlugin() | ||
]; | ||
function generateConfig(name) { | ||
var uglify = name.indexOf('min') > -1; | ||
var config = { | ||
entry: './index.js', | ||
output: { | ||
path: 'dist/', | ||
filename: name + '.js', | ||
sourceMapFilename: name + '.map', | ||
library: 'axios', | ||
libraryTarget: 'umd' | ||
}, | ||
externals: [ | ||
{ | ||
'./adapters/http': 'var undefined' | ||
} | ||
], | ||
devtool: 'source-map' | ||
}; | ||
|
||
if (uglify) { | ||
config.plugins = [ | ||
new webpack.optimize.UglifyJsPlugin({ | ||
compressor: { | ||
warnings: false | ||
} | ||
}) | ||
]; | ||
} | ||
|
||
return config; | ||
} | ||
|
||
['axios', 'axios.min'].forEach(function (key) { | ||
config[key] = generateConfig(key); | ||
}); | ||
|
||
config['amd'].output.filename = 'axios.amd.js'; | ||
config['amd'].output.sourceMapFilename = 'axios.amd.map'; | ||
config['amd'].output.libraryTarget = 'amd'; | ||
|
||
config['amd-standalone'].output.filename = 'axios.amd.standalone.js'; | ||
config['amd-standalone'].output.sourceMapFilename = 'axios.amd.standalone.map'; | ||
config['amd-standalone'].output.libraryTarget = 'amd'; | ||
config['amd-standalone'].externals[0]['es6-promise'] = EXTERNAL_PROMISE; | ||
|
||
config['amd-min'].output.filename = 'axios.amd.min.js'; | ||
config['amd-min'].output.sourceMapFilename = 'axios.amd.min.map'; | ||
config['amd-min'].output.libraryTarget = 'amd'; | ||
|
||
config['amd-standalone-min'].output.filename = 'axios.amd.standalone.min.js'; | ||
config['amd-standalone-min'].output.sourceMapFilename = 'axios.amd.standalone.min.map'; | ||
config['amd-standalone-min'].output.libraryTarget = 'amd'; | ||
config['amd-standalone-min'].externals[0]['es6-promise'] = EXTERNAL_PROMISE; | ||
|
||
config['global-standalone'].output.filename = 'axios.standalone.js'; | ||
config['global-standalone'].output.sourceMapFilename = 'axios.standalone.map'; | ||
config['global-standalone'].externals[0]['es6-promise'] = EXTERNAL_PROMISE; | ||
|
||
config['global-min'].output.filename = 'axios.min.js'; | ||
config['global-min'].output.sourceMapFilename = 'axios.min.map'; | ||
|
||
config['global-standalone-min'].output.filename = 'axios.standalone.min.js'; | ||
config['global-standalone-min'].output.sourceMapFilename = 'axios.standalone.min.map'; | ||
config['global-standalone-min'].externals[0]['es6-promise'] = EXTERNAL_PROMISE; | ||
|
||
module.exports = config; | ||
|