redoc/build/webpack.prod.js

86 lines
2.3 KiB
JavaScript
Raw Normal View History

2016-08-28 21:46:10 +03:00
const webpack = require('webpack');
const V8LazyParseWebpackPlugin = require('v8-lazy-parse-webpack-plugin');
2016-08-28 21:46:10 +03:00
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/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'),
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: [
'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
}),
new webpack.optimize.UglifyJsPlugin({
compress: {
warnings: false,
screw_ie8: true,
negate_iife: false // for lazy v8
2016-08-28 21:46:10 +03:00
},
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
}),
new webpack.BannerPlugin(BANNER),
new V8LazyParseWebpackPlugin()
]
})
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;