redoc/build/webpack.prod.js

84 lines
2.1 KiB
JavaScript
Raw Permalink Normal View History

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;
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
const IS_MODULE = process.env.IS_MODULE != null;
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
}), {
devtool: 'source-map',
2016-08-28 21:46:10 +03:00
entry: {
'redoc': IS_MODULE ? ['./lib/redoc.module.ts'] : ['./lib/polyfills.ts', './lib/index.ts']
2016-08-28 21:46:10 +03:00
},
output: {
path: root('dist'),
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: {
rules: [
{
test: /\.ts$/,
use: [
2017-05-08 11:24:25 +03:00
'awesome-typescript-loader',
'angular2-template-loader',
],
exclude: [/\.(spec|e2e)\.ts$/]
}
]
2016-08-28 21:46:10 +03:00
},
plugins: [
new webpack.LoaderOptionsPlugin({
minimize: true,
debug: false
}),
2017-04-19 12:41:38 +03:00
new webpack.optimize.UglifyJsPlugin({
compress: {
warnings: false,
2017-06-26 12:52:33 +03:00
screw_ie8: true
2017-04-19 12:41:38 +03:00
},
mangle: { screw_ie8 : true },
output: {
comments: false
},
sourceMap: true
}),
2017-05-08 11:24:25 +03:00
new webpack.optimize.ModuleConcatenationPlugin(),
new webpack.BannerPlugin(BANNER)
]
})
if (IS_MODULE) {
config.externals = {
'jquery': 'jquery',
'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;