Skip to content

Commit b4cd69f

Browse files
committed
updated webpack terser options
1 parent 2c6a4ed commit b4cd69f

File tree

2 files changed

+28
-8
lines changed

2 files changed

+28
-8
lines changed

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "rapidoc",
3-
"version": "8.4.9-beta-1",
3+
"version": "8.4.9",
44
"description": "RapiDoc - Open API spec viewer with built in console",
55
"author": "Mrinmoy Majumdar <[email protected]>",
66
"repository": {
@@ -39,6 +39,7 @@
3939
"build": "NODE_ENV=production webpack --mode=production",
4040
"build_windows": "set NODE_ENV='production'&&webpack --mode=production",
4141
"serve": "webpack serve --mode=development",
42+
"serve-prod": "webpack serve --mode=production",
4243
"serve1": "node --trace-deprecation ./node_modules/webpack/bin/webpack serve",
4344
"lint": "./node_modules/eslint/bin/eslint.js ./src/**",
4445
"lint-fix": "./node_modules/eslint/bin/eslint.js --fix ./src/**"
@@ -62,6 +63,7 @@
6263
"html-webpack-plugin": "^5.3.1",
6364
"inspectpack": "^4.6.1",
6465
"style-loader": "^2.0.0",
66+
"terser-webpack-plugin": "^5.1.1",
6567
"webpack": "^5.25.0",
6668
"webpack-bundle-analyzer": "^4.4.0",
6769
"webpack-cli": "^4.5.0",

webpack.config.js

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,20 @@ const CompressionPlugin = require('compression-webpack-plugin');
1717
const { DuplicatesPlugin } = require('inspectpack/plugin');
1818
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
1919
const HtmlWebpackPlugin = require('html-webpack-plugin');
20+
const TerserPlugin = require('terser-webpack-plugin');
2021
const path = require('path');
2122
// const ESLintPlugin = require('eslint-webpack-plugin');
2223

23-
const VERSION = JSON.stringify(require('./package.json').version).replace(/"/g, '');
24+
const rapidocVersion = JSON.stringify(require('./package.json').version).replace(/"/g, '');
2425

25-
const BANNER = `RapiDoc ${VERSION.replace()} - WebComponent to View OpenAPI docs
26-
License: MIT
27-
Repo : https://github.com/mrin9/RapiDoc
28-
Author : Mrinmoy Majumdar`;
26+
const rapidocBanner = `
27+
/**
28+
* @preserve
29+
* RapiDoc ${rapidocVersion.replace()} - WebComponent to View OpenAPI docs
30+
* License: MIT
31+
* Repo : https://github.com/mrin9/RapiDoc
32+
* Author : Mrinmoy Majumdar
33+
*`;
2934

3035
const commonPlugins = [
3136
new webpack.ProvidePlugin({ Buffer: ['buffer', 'Buffer'] }),
@@ -62,8 +67,11 @@ if (process.env.NODE_ENV === 'production') {
6267
console.log('BUILDING FOR PRODUCTION ... '); // eslint-disable-line no-console
6368
commonPlugins.push(new BundleAnalyzerPlugin({ analyzerMode: 'static' }));
6469
commonPlugins.push(new DuplicatesPlugin({ emitErrors: false, verbose: true }));
65-
commonPlugins.push(new webpack.BannerPlugin(BANNER));
66-
commonPlugins.push(new webpack.DefinePlugin({ VERSION }));
70+
commonPlugins.push(new webpack.BannerPlugin({
71+
raw: true,
72+
banner: rapidocBanner,
73+
}));
74+
// commonPlugins.push(new webpack.DefinePlugin({ VERSION }));
6775
commonPlugins.push(new FileManagerPlugin({
6876
events: {
6977
onEnd: {
@@ -85,6 +93,16 @@ module.exports = {
8593
filename: 'rapidoc-min.js',
8694
publicPath: '',
8795
},
96+
optimization: {
97+
minimizer: [
98+
new TerserPlugin({
99+
extractComments: {
100+
condition: /^\**!|@preserve|@license|@cc_on/i,
101+
banner: (licenseFile) => `RapiDoc ${rapidocVersion} - License information can be found in ${licenseFile}`,
102+
},
103+
}),
104+
],
105+
},
88106
devServer: {
89107
contentBase: path.join(__dirname, 'docs'),
90108
port: 8080,

0 commit comments

Comments
 (0)