2016-08-28 21:46:10 +03:00
|
|
|
const webpack = require('webpack');
|
|
|
|
|
|
|
|
const VERSION = JSON.stringify(require('../package.json').version);
|
|
|
|
|
|
|
|
const root = require('./helpers').root;
|
2016-08-30 19:53:06 +03:00
|
|
|
const BANNER =
|
|
|
|
`ReDoc - OpenAPI/Swagger-generated API Reference Documentation
|
|
|
|
-------------------------------------------------------------
|
|
|
|
Version: ${VERSION}
|
|
|
|
Repo: https://github.com/Rebilly/ReDoc`;
|
2016-08-28 21:46:10 +03:00
|
|
|
|
2016-10-14 11:44:48 +03:00
|
|
|
const IS_MODULE = process.env.IS_MODULE != null;
|
|
|
|
|
|
|
|
const config = {
|
2016-08-28 21:46:10 +03:00
|
|
|
context: root(),
|
2016-09-02 23:24:51 +03:00
|
|
|
devtool: 'source-map',
|
2016-12-19 23:58:39 +03:00
|
|
|
performance: { hints: false },
|
2016-08-28 21:46:10 +03:00
|
|
|
|
|
|
|
resolve: {
|
2016-09-27 09:03:04 +03:00
|
|
|
extensions: ['.ts', '.js', '.json', '.css'],
|
2016-08-28 21:46:10 +03:00
|
|
|
alias: {
|
|
|
|
http: 'stream-http',
|
|
|
|
https: 'stream-http'
|
|
|
|
}
|
|
|
|
},
|
|
|
|
externals: {
|
2016-10-18 17:06:00 +03:00
|
|
|
'jquery': 'jquery',
|
2016-09-02 23:24:51 +03:00
|
|
|
'esprima': 'esprima' // optional dep of ys-yaml not needed for redoc
|
2016-08-28 21:46:10 +03:00
|
|
|
},
|
|
|
|
node: {
|
2016-09-02 23:24:51 +03:00
|
|
|
fs: "empty",
|
|
|
|
crypto: "empty",
|
2016-09-27 09:03:04 +03:00
|
|
|
global: true,
|
2016-09-02 23:24:51 +03:00
|
|
|
process: true,
|
|
|
|
module: false,
|
|
|
|
clearImmediate: false,
|
|
|
|
setImmediate: false
|
2016-08-28 21:46:10 +03:00
|
|
|
},
|
|
|
|
entry: {
|
2016-10-14 11:44:48 +03:00
|
|
|
'redoc': IS_MODULE ? ['./lib/vendor.ts', './lib/redoc.module.ts'] : ['./lib/polyfills.ts', './lib/vendor.ts', './lib/index.ts']
|
2016-08-28 21:46:10 +03:00
|
|
|
},
|
|
|
|
|
|
|
|
output: {
|
|
|
|
path: root('dist'),
|
2016-10-14 11:44:48 +03:00
|
|
|
filename: IS_MODULE ? '[name]-module.js' : '[name].min.js',
|
|
|
|
sourceMapFilename: IS_MODULE ? '[name]-module.map' : '[name].min.map',
|
2016-08-28 21:46:10 +03:00
|
|
|
library: 'Redoc',
|
|
|
|
libraryTarget: 'umd',
|
|
|
|
umdNamedDefine: true
|
|
|
|
},
|
|
|
|
|
|
|
|
module: {
|
2016-09-28 00:30:33 +03:00
|
|
|
exprContextCritical: false,
|
|
|
|
rules: [{
|
2016-09-27 09:03:04 +03:00
|
|
|
enforce: 'pre',
|
2016-08-29 07:35:47 +03:00
|
|
|
test: /\.js$/,
|
2016-09-02 23:24:51 +03:00
|
|
|
loader: 'source-map-loader',
|
|
|
|
exclude: [
|
|
|
|
/node_modules/
|
|
|
|
]
|
2016-10-31 22:09:55 +03:00
|
|
|
}, {
|
|
|
|
test: /node_modules\/.*\.ngfactory\.ts$/,
|
|
|
|
loader: 'awesome-typescript-loader'
|
|
|
|
}, {
|
|
|
|
test: /\.ts$/,
|
|
|
|
loader: 'awesome-typescript-loader',
|
|
|
|
exclude: /(node_modules)/,
|
|
|
|
}, {
|
2016-10-14 11:44:48 +03:00
|
|
|
test: /lib[\\\/].*\.css$/,
|
|
|
|
loaders: ['raw-loader'],
|
|
|
|
exclude: [/redoc-initial-styles\.css$/]
|
2016-08-28 21:46:10 +03:00
|
|
|
}, {
|
|
|
|
test: /\.css$/,
|
2016-11-29 10:20:11 +03:00
|
|
|
loaders: ['style-loader', 'css-loader?-import'],
|
2016-10-14 11:44:48 +03:00
|
|
|
exclude: [/lib[\\\/](?!.*redoc-initial-styles).*\.css$/]
|
2016-08-28 21:46:10 +03:00
|
|
|
}]
|
|
|
|
},
|
|
|
|
|
|
|
|
plugins: [
|
|
|
|
new webpack.LoaderOptionsPlugin({
|
|
|
|
minimize: true,
|
|
|
|
debug: false
|
|
|
|
}),
|
|
|
|
new webpack.optimize.UglifyJsPlugin({
|
|
|
|
compress: {
|
|
|
|
warnings: false,
|
|
|
|
screw_ie8: true
|
|
|
|
},
|
|
|
|
mangle: { screw_ie8 : true },
|
|
|
|
output: {
|
|
|
|
comments: false
|
|
|
|
},
|
2016-08-29 07:35:47 +03:00
|
|
|
sourceMap: true
|
2016-08-28 21:46:10 +03:00
|
|
|
}),
|
2016-08-30 19:53:06 +03:00
|
|
|
new webpack.BannerPlugin(BANNER),
|
2016-08-28 21:46:10 +03:00
|
|
|
new webpack.DefinePlugin({
|
|
|
|
'IS_PRODUCTION': true,
|
2016-09-28 00:30:33 +03:00
|
|
|
'LIB_VERSION': VERSION,
|
|
|
|
'AOT': true
|
2016-08-28 21:46:10 +03:00
|
|
|
})
|
|
|
|
],
|
|
|
|
}
|
2016-10-14 11:44:48 +03:00
|
|
|
|
|
|
|
if (IS_MODULE) {
|
|
|
|
config.externals = {
|
2016-10-18 17:46:41 +03:00
|
|
|
'jquery': 'jquery',
|
2016-10-14 11:44:48 +03:00
|
|
|
'esprima': 'esprima', // optional dep of ys-yaml not needed for redoc
|
|
|
|
'@angular/platform-browser-dynamic': '@angular/platform-browser-dynamic',
|
|
|
|
'@angular/platform-browser': '@angular/platform-browser',
|
|
|
|
'@angular/core': '@angular/core',
|
|
|
|
'@angular/common': '@angular/common',
|
|
|
|
'@angular/forms': '@angular/forms',
|
|
|
|
'core-js': 'core-js',
|
|
|
|
'rxjs': 'rxjs',
|
|
|
|
'zone.js/dist/zone': 'zone.js/dist/zone'
|
|
|
|
};
|
|
|
|
|
|
|
|
config.module.rules.push({
|
|
|
|
test: /\.ts$/,
|
|
|
|
loader: 'angular2-template-loader',
|
|
|
|
exclude: [/\.(spec|e2e)\.ts$/]
|
|
|
|
});
|
|
|
|
|
|
|
|
config.module.rules.push({
|
|
|
|
test: /\.html$/,
|
|
|
|
loader: 'raw-loader'
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = config;
|