redoc/build/webpack.prod.js

130 lines
3.1 KiB
JavaScript
Raw 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 config = {
2016-08-28 21:46:10 +03:00
context: root(),
devtool: 'source-map',
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',
'esprima': 'esprima' // optional dep of ys-yaml not needed for redoc
2016-08-28 21:46:10 +03:00
},
node: {
fs: "empty",
crypto: "empty",
2016-09-27 09:03:04 +03:00
global: true,
process: true,
module: false,
clearImmediate: false,
setImmediate: false
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: {
exprContextCritical: false,
rules: [{
2016-09-27 09:03:04 +03:00
enforce: 'pre',
2016-08-29 07:35:47 +03:00
test: /\.js$/,
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)/,
}, {
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'],
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
}),
new webpack.BannerPlugin(BANNER),
2016-08-28 21:46:10 +03:00
new webpack.DefinePlugin({
'IS_PRODUCTION': true,
'LIB_VERSION': VERSION,
'AOT': true
2016-08-28 21:46:10 +03:00
})
],
}
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'
};
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;