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;
|
|
|
|
|
2017-01-06 22:38:04 +03:00
|
|
|
const webpackMerge = require('webpack-merge'); // used to merge webpack configs
|
|
|
|
const commonConfig = require('./webpack.common.js');
|
|
|
|
|
|
|
|
const config = webpackMerge(commonConfig({
|
|
|
|
IS_PRODUCTION: true,
|
|
|
|
AOT: true
|
|
|
|
}), {
|
2016-09-02 23:24:51 +03:00
|
|
|
devtool: 'source-map',
|
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: {
|
2017-01-06 22:38:04 +03:00
|
|
|
rules: [
|
|
|
|
{
|
|
|
|
test: /\.ts$/,
|
|
|
|
use: [
|
|
|
|
'awesome-typescript-loader?{configFileName: "tsconfig.webpack.json"}',
|
|
|
|
'angular2-template-loader',
|
|
|
|
],
|
|
|
|
exclude: [/\.(spec|e2e)\.ts$/]
|
|
|
|
}
|
|
|
|
]
|
2016-08-28 21:46:10 +03:00
|
|
|
},
|
|
|
|
plugins: [
|
|
|
|
new webpack.LoaderOptionsPlugin({
|
|
|
|
minimize: true,
|
|
|
|
debug: false
|
|
|
|
}),
|
2017-01-28 15:06:25 +03:00
|
|
|
new webpack.BannerPlugin(BANNER)
|
2017-01-06 22:38:04 +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'
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = config;
|