@@ -17,15 +17,20 @@ const CompressionPlugin = require('compression-webpack-plugin');
17
17
const { DuplicatesPlugin } = require ( 'inspectpack/plugin' ) ;
18
18
const { CleanWebpackPlugin } = require ( 'clean-webpack-plugin' ) ;
19
19
const HtmlWebpackPlugin = require ( 'html-webpack-plugin' ) ;
20
+ const TerserPlugin = require ( 'terser-webpack-plugin' ) ;
20
21
const path = require ( 'path' ) ;
21
22
// const ESLintPlugin = require('eslint-webpack-plugin');
22
23
23
- const VERSION = JSON . stringify ( require ( './package.json' ) . version ) . replace ( / " / g, '' ) ;
24
+ const rapidocVersion = JSON . stringify ( require ( './package.json' ) . version ) . replace ( / " / g, '' ) ;
24
25
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
+ *` ;
29
34
30
35
const commonPlugins = [
31
36
new webpack . ProvidePlugin ( { Buffer : [ 'buffer' , 'Buffer' ] } ) ,
@@ -62,8 +67,11 @@ if (process.env.NODE_ENV === 'production') {
62
67
console . log ( 'BUILDING FOR PRODUCTION ... ' ) ; // eslint-disable-line no-console
63
68
commonPlugins . push ( new BundleAnalyzerPlugin ( { analyzerMode : 'static' } ) ) ;
64
69
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 }));
67
75
commonPlugins . push ( new FileManagerPlugin ( {
68
76
events : {
69
77
onEnd : {
@@ -85,6 +93,16 @@ module.exports = {
85
93
filename : 'rapidoc-min.js' ,
86
94
publicPath : '' ,
87
95
} ,
96
+ optimization : {
97
+ minimizer : [
98
+ new TerserPlugin ( {
99
+ extractComments : {
100
+ condition : / ^ \* * ! | @ p r e s e r v e | @ l i c e n s e | @ c c _ o n / i,
101
+ banner : ( licenseFile ) => `RapiDoc ${ rapidocVersion } - License information can be found in ${ licenseFile } ` ,
102
+ } ,
103
+ } ) ,
104
+ ] ,
105
+ } ,
88
106
devServer : {
89
107
contentBase : path . join ( __dirname , 'docs' ) ,
90
108
port : 8080 ,
0 commit comments