rapidoc 9.3.8 → 10.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +193 -61
- package/dist/rapidoc-min.js +279 -3914
- package/package.json +23 -46
- package/.babelrc.json +0 -42
- package/.eslintrc +0 -53
- package/.github/FUNDING.yml +0 -13
- package/.github/workflow/words.yaml +0 -22
- package/CONTRIBUTING.md +0 -35
- package/dist/index.html +0 -1010
- package/dist/index.html.gz +0 -0
- package/dist/rapidoc-min.js.LICENSE.txt +0 -64
- package/dist/rapidoc-min.js.LICENSE.txt.gz +0 -0
- package/dist/rapidoc-min.js.gz +0 -0
- package/dist/rapidoc-min.js.map +0 -1
- package/dist/rapidoc-min.js.map.gz +0 -0
- package/dist/rapidoc.js +0 -21603
- package/dist/report.html +0 -39
- package/index-hashroute.html +0 -65
- package/index.html +0 -1045
- package/index_bak.html +0 -251
- package/jsconfig.json +0 -11
- package/logo.png +0 -0
- package/performance.html +0 -31
- package/src/components/api-request.js +0 -1793
- package/src/components/api-response.js +0 -335
- package/src/components/dialog-box.js +0 -73
- package/src/components/json-tree.js +0 -145
- package/src/components/schema-table.js +0 -367
- package/src/components/schema-tree.js +0 -381
- package/src/components/tag-input.js +0 -135
- package/src/index.js +0 -7
- package/src/json-schema-viewer.js +0 -346
- package/src/oauth-receiver.js +0 -56
- package/src/rapidoc-mini.js +0 -382
- package/src/rapidoc.js +0 -1083
- package/src/styles/border-styles.js +0 -24
- package/src/styles/custom-styles.js +0 -10
- package/src/styles/dialog-box-styles.js +0 -75
- package/src/styles/endpoint-styles.js +0 -202
- package/src/styles/flex-styles.js +0 -15
- package/src/styles/font-styles.js +0 -268
- package/src/styles/info-styles.js +0 -21
- package/src/styles/input-styles.js +0 -207
- package/src/styles/nav-styles.js +0 -198
- package/src/styles/prism-styles.js +0 -105
- package/src/styles/schema-styles.js +0 -121
- package/src/styles/tab-styles.js +0 -47
- package/src/styles/table-styles.js +0 -58
- package/src/templates/advance-search-template.js +0 -72
- package/src/templates/callback-template.js +0 -75
- package/src/templates/code-samples-template.js +0 -34
- package/src/templates/components-template.js +0 -76
- package/src/templates/endpoint-template.js +0 -251
- package/src/templates/expanded-endpoint-template.js +0 -199
- package/src/templates/focused-endpoint-template.js +0 -110
- package/src/templates/header-template.js +0 -66
- package/src/templates/json-schema-viewer-template.js +0 -185
- package/src/templates/logo-template.js +0 -18
- package/src/templates/main-body-template.js +0 -110
- package/src/templates/navbar-template.js +0 -272
- package/src/templates/overview-template.js +0 -79
- package/src/templates/security-scheme-template.js +0 -612
- package/src/templates/server-template.js +0 -115
- package/src/utils/color-utils.js +0 -59
- package/src/utils/common-utils.js +0 -168
- package/src/utils/schema-utils.js +0 -1086
- package/src/utils/spec-parser.js +0 -462
- package/src/utils/theme.js +0 -288
- package/webpack.config.js +0 -142
package/src/utils/theme.js
DELETED
|
@@ -1,288 +0,0 @@
|
|
|
1
|
-
import { html } from 'lit';
|
|
2
|
-
import ColorUtils from '~/utils/color-utils';
|
|
3
|
-
/* Generates an schema object containing type and constraint info */
|
|
4
|
-
export default function setTheme(baseTheme, theme = {}) {
|
|
5
|
-
let newTheme = {};
|
|
6
|
-
|
|
7
|
-
// Common Theme colors
|
|
8
|
-
const primaryColor = theme.primaryColor ? theme.primaryColor : baseTheme === 'dark' ? '#f76b39' : '#ff591e';
|
|
9
|
-
const primaryColorInvert = ColorUtils.color.invert(primaryColor);
|
|
10
|
-
const primaryColorTrans = ColorUtils.color.opacity(primaryColor, '0.4');
|
|
11
|
-
|
|
12
|
-
// Dark and Light Theme colors
|
|
13
|
-
if (baseTheme === 'dark') {
|
|
14
|
-
const bg1 = theme.bg1 ? theme.bg1 : '#2a2b2c';
|
|
15
|
-
const fg1 = theme.fg1 ? theme.fg1 : '#bbb';
|
|
16
|
-
|
|
17
|
-
const bg2 = theme.bg2 ? theme.bg2 : ColorUtils.color.brightness(bg1, 5); // or #383838;
|
|
18
|
-
const bg3 = theme.bg3 ? theme.bg3 : ColorUtils.color.brightness(bg1, 17); // or #444;
|
|
19
|
-
const lightBg = theme.bg3 ? theme.bg3 : ColorUtils.color.brightness(bg1, 35);
|
|
20
|
-
const fg2 = theme.fg2 ? theme.fg2 : ColorUtils.color.brightness(fg1, -15); // or #ababab
|
|
21
|
-
const fg3 = theme.fg3 ? theme.fg3 : ColorUtils.color.brightness(fg1, -20); // or #aaa
|
|
22
|
-
const lightFg = theme.fg3 ? theme.fg3 : ColorUtils.color.brightness(fg1, -65); // or #777
|
|
23
|
-
const inlineCodeFg = theme.inlineCodeFg ? theme.inlineCodeFg : '#aaa';
|
|
24
|
-
const selectionBg = fg2;
|
|
25
|
-
const selectionFg = bg2;
|
|
26
|
-
|
|
27
|
-
const headerColor = theme.headerColor ? theme.headerColor : ColorUtils.color.brightness(bg1, 10);
|
|
28
|
-
|
|
29
|
-
const navBgColor = theme.navBgColor ? theme.navBgColor : ColorUtils.color.brightness(bg1, 10);
|
|
30
|
-
const navTextColor = theme.navTextColor ? theme.navTextColor : ColorUtils.color.opacity(ColorUtils.color.invert(navBgColor), '0.50');
|
|
31
|
-
const navHoverBgColor = theme.navHoverBgColor ? theme.navHoverBgColor : ColorUtils.color.brightness(navBgColor, -15);
|
|
32
|
-
const navHoverTextColor = theme.navHoverTextColor ? theme.navHoverTextColor : ColorUtils.color.invert(navBgColor);
|
|
33
|
-
const navAccentColor = theme.navAccentColor ? theme.navAccentColor : ColorUtils.color.brightness(primaryColor, 25);
|
|
34
|
-
const navAccentTextColor = theme.navAccentTextColor ? theme.navAccenttextColor : ColorUtils.color.invert(navAccentColor);
|
|
35
|
-
|
|
36
|
-
const overlayBg = 'rgba(80, 80, 80, 0.4)';
|
|
37
|
-
|
|
38
|
-
newTheme = {
|
|
39
|
-
bg1,
|
|
40
|
-
bg2,
|
|
41
|
-
bg3,
|
|
42
|
-
lightBg,
|
|
43
|
-
fg1,
|
|
44
|
-
fg2,
|
|
45
|
-
fg3,
|
|
46
|
-
lightFg,
|
|
47
|
-
inlineCodeFg,
|
|
48
|
-
primaryColor,
|
|
49
|
-
primaryColorTrans,
|
|
50
|
-
primaryColorInvert,
|
|
51
|
-
selectionBg,
|
|
52
|
-
selectionFg,
|
|
53
|
-
overlayBg,
|
|
54
|
-
navBgColor,
|
|
55
|
-
navTextColor,
|
|
56
|
-
navHoverBgColor,
|
|
57
|
-
navHoverTextColor,
|
|
58
|
-
navAccentColor,
|
|
59
|
-
navAccentTextColor,
|
|
60
|
-
headerColor,
|
|
61
|
-
headerColorInvert: ColorUtils.color.invert(headerColor),
|
|
62
|
-
headerColorDarker: ColorUtils.color.brightness(headerColor, -20),
|
|
63
|
-
headerColorBorder: ColorUtils.color.brightness(headerColor, 10),
|
|
64
|
-
|
|
65
|
-
borderColor: theme.borderColor || ColorUtils.color.brightness(bg1, 20), // #555
|
|
66
|
-
lightBorderColor: theme.lightBorderColor || ColorUtils.color.brightness(bg1, 15), // #444
|
|
67
|
-
codeBorderColor: theme.codeBorderColor || ColorUtils.color.brightness(bg1, 30),
|
|
68
|
-
|
|
69
|
-
inputBg: theme.inputBg || ColorUtils.color.brightness(bg1, -5), // #2f2f2f
|
|
70
|
-
placeHolder: theme.placeHolder || ColorUtils.color.opacity(fg1, '0.3'),
|
|
71
|
-
hoverColor: theme.hoverColor || ColorUtils.color.brightness(bg1, -10), // #2a2a2a
|
|
72
|
-
|
|
73
|
-
red: theme.red ? theme.red : '#F06560',
|
|
74
|
-
lightRed: theme.lightRed ? theme.lightRed : ColorUtils.color.brightness(bg1, -10), // #2a2a2a
|
|
75
|
-
|
|
76
|
-
pink: theme.pink ? theme.pink : '#ffb2b2',
|
|
77
|
-
lightPink: theme.lightPink || ColorUtils.color.brightness(bg1, -10),
|
|
78
|
-
|
|
79
|
-
green: theme.green || '#7ec699',
|
|
80
|
-
lightGreen: theme.lightGreen || ColorUtils.color.brightness(bg1, -10), // #2a2a2a
|
|
81
|
-
|
|
82
|
-
blue: theme.blue || '#71b7ff',
|
|
83
|
-
lightBlue: theme.lightBlue || ColorUtils.color.brightness(bg1, -10), // #2a2a2a
|
|
84
|
-
|
|
85
|
-
orange: theme.orange ? theme.orange : '#f08d49',
|
|
86
|
-
lightOrange: theme.lightOrange || ColorUtils.color.brightness(bg1, -10), // #2a2a2a
|
|
87
|
-
|
|
88
|
-
yellow: theme.yellow || '#827717',
|
|
89
|
-
lightYellow: theme.lightYellow || ColorUtils.color.brightness(bg1, -10), // #2a2a2a
|
|
90
|
-
|
|
91
|
-
purple: theme.purple || '#786FF1',
|
|
92
|
-
brown: theme.brown || '#D4AC0D',
|
|
93
|
-
|
|
94
|
-
codeBg: theme.codeBg || ColorUtils.color.opacity(ColorUtils.color.brightness(bg1, -15), 0.7),
|
|
95
|
-
codeFg: theme.codeFg || '#aaa',
|
|
96
|
-
codePropertyColor: theme.codePropertyColor || '#f8c555',
|
|
97
|
-
codeKeywordColor: theme.codeKeywordColor || '#cc99cd',
|
|
98
|
-
codeOperatorColor: theme.codeOperatorColor || '#67cdcc',
|
|
99
|
-
};
|
|
100
|
-
} else {
|
|
101
|
-
const bg1 = (theme.bg1 ? theme.bg1 : '#fafbfc');
|
|
102
|
-
const fg1 = (theme.fg1 ? theme.fg1 : '#444444');
|
|
103
|
-
const bg2 = theme.bg2 ? theme.bg2 : ColorUtils.color.brightness(bg1, -5); // or '#fafafa'
|
|
104
|
-
const bg3 = theme.bg3 ? theme.bg3 : ColorUtils.color.brightness(bg1, -15); // or '#f6f6f6'
|
|
105
|
-
const lightBg = theme.bg3 ? theme.bg3 : ColorUtils.color.brightness(bg1, -45);
|
|
106
|
-
const fg2 = theme.fg2 ? theme.fg2 : ColorUtils.color.brightness(fg1, 17); // or '#555'
|
|
107
|
-
const fg3 = theme.fg3 ? theme.fg3 : ColorUtils.color.brightness(fg1, 30); // or #666
|
|
108
|
-
const lightFg = theme.fg3 ? theme.fg3 : ColorUtils.color.brightness(fg1, 70); // or #999
|
|
109
|
-
const inlineCodeFg = theme.inlineCodeFg ? theme.inlineCodeFg : 'brown';
|
|
110
|
-
const selectionBg = fg2;
|
|
111
|
-
const selectionFg = bg2;
|
|
112
|
-
const headerColor = theme.headerColor ? theme.headerColor : ColorUtils.color.brightness(bg1, -180);
|
|
113
|
-
|
|
114
|
-
/*
|
|
115
|
-
const navBgColor = theme.navBgColor ? theme.navBgColor : ColorUtils.color.brightness(bg1, -10);
|
|
116
|
-
const navTextColor = theme.navTextColor ? theme.navTextColor : ColorUtils.color.brightness(fg1, 5);
|
|
117
|
-
const navHoverBgColor = theme.navHoverBgColor ? theme.navHoverBgColor : bg1;
|
|
118
|
-
const navHoverTextColor = theme.navHoverTextColor ? theme.navHoverTextColor : primaryColor;
|
|
119
|
-
const navAccentColor = theme.navAccentColor ? theme.navAccentColor : primaryColor;
|
|
120
|
-
*/
|
|
121
|
-
const navBgColor = theme.navBgColor ? theme.navBgColor : ColorUtils.color.brightness(bg1, -200);
|
|
122
|
-
const navTextColor = theme.navTextColor ? theme.navTextColor : ColorUtils.color.opacity(ColorUtils.color.invert(navBgColor), '0.65');
|
|
123
|
-
const navHoverBgColor = theme.navHoverBgColor ? theme.navHoverBgColor : ColorUtils.color.brightness(navBgColor, -15);
|
|
124
|
-
const navHoverTextColor = theme.navHoverTextColor ? theme.navHoverTextColor : ColorUtils.color.invert(navBgColor);
|
|
125
|
-
const navAccentColor = theme.navAccentColor ? theme.navAccentColor : ColorUtils.color.brightness(primaryColor, 25);
|
|
126
|
-
const navAccentTextColor = theme.navAccentTextColor ? theme.navAccenttextColor : ColorUtils.color.invert(navAccentColor);
|
|
127
|
-
const overlayBg = 'rgba(0, 0, 0, 0.4)';
|
|
128
|
-
|
|
129
|
-
newTheme = {
|
|
130
|
-
bg1,
|
|
131
|
-
bg2,
|
|
132
|
-
bg3,
|
|
133
|
-
lightBg,
|
|
134
|
-
fg1,
|
|
135
|
-
fg2,
|
|
136
|
-
fg3,
|
|
137
|
-
lightFg,
|
|
138
|
-
inlineCodeFg,
|
|
139
|
-
primaryColor,
|
|
140
|
-
primaryColorTrans,
|
|
141
|
-
primaryColorInvert,
|
|
142
|
-
selectionBg,
|
|
143
|
-
selectionFg,
|
|
144
|
-
overlayBg,
|
|
145
|
-
navBgColor,
|
|
146
|
-
navTextColor,
|
|
147
|
-
navHoverBgColor,
|
|
148
|
-
navHoverTextColor,
|
|
149
|
-
navAccentColor,
|
|
150
|
-
navAccentTextColor,
|
|
151
|
-
headerColor,
|
|
152
|
-
headerColorInvert: ColorUtils.color.invert(headerColor),
|
|
153
|
-
headerColorDarker: ColorUtils.color.brightness(headerColor, -20),
|
|
154
|
-
headerColorBorder: ColorUtils.color.brightness(headerColor, 10),
|
|
155
|
-
|
|
156
|
-
borderColor: theme.borderColor || ColorUtils.color.brightness(bg1, -38),
|
|
157
|
-
lightBorderColor: theme.lightBorderColor || ColorUtils.color.brightness(bg1, -23),
|
|
158
|
-
codeBorderColor: theme.codeBorderColor || 'transparent',
|
|
159
|
-
|
|
160
|
-
inputBg: theme.inputBg || ColorUtils.color.brightness(bg1, 10), // #fff
|
|
161
|
-
placeHolder: theme.placeHolder || ColorUtils.color.brightness(lightFg, 20), // #dedede
|
|
162
|
-
hoverColor: theme.hoverColor || ColorUtils.color.brightness(bg1, -5), // # f1f1f1
|
|
163
|
-
|
|
164
|
-
red: theme.red || '#F06560',
|
|
165
|
-
lightRed: theme.lightRed || '#fff0f0',
|
|
166
|
-
|
|
167
|
-
pink: theme.pink ? theme.pink : '#990055',
|
|
168
|
-
lightPink: theme.lightPink ? theme.lightPink : '#ffb2b2',
|
|
169
|
-
|
|
170
|
-
green: theme.green || '#690',
|
|
171
|
-
lightGreen: theme.lightGreen || '#fbfff0',
|
|
172
|
-
|
|
173
|
-
blue: theme.blue || '#47AFE8',
|
|
174
|
-
lightBlue: theme.lightBlue || '#eff8fd',
|
|
175
|
-
|
|
176
|
-
orange: theme.orange || '#FF9900',
|
|
177
|
-
lightOrange: theme.lightOrange || '#fff5e6',
|
|
178
|
-
|
|
179
|
-
yellow: theme.yellow || '#827717',
|
|
180
|
-
lightYellow: theme.lightYellow || '#fff5cc',
|
|
181
|
-
|
|
182
|
-
purple: theme.purple || '#786FF1',
|
|
183
|
-
brown: theme.brown || '#D4AC0D',
|
|
184
|
-
|
|
185
|
-
codeBg: theme.codeBg || ColorUtils.color.opacity(ColorUtils.color.brightness(bg1, -15), 0.7),
|
|
186
|
-
codeFg: theme.codeFg || '#666',
|
|
187
|
-
codePropertyColor: theme.codePropertyColor || '#905',
|
|
188
|
-
codeKeywordColor: theme.codeKeywordColor || '#07a',
|
|
189
|
-
codeOperatorColor: theme.codeOperatorColor || '#9a6e3a',
|
|
190
|
-
};
|
|
191
|
-
}
|
|
192
|
-
return html`
|
|
193
|
-
<style>
|
|
194
|
-
*, *:before, *:after { box-sizing: border-box; }
|
|
195
|
-
|
|
196
|
-
:host {
|
|
197
|
-
/* Common Styles - irrespective of themes */
|
|
198
|
-
--border-radius: 2px;
|
|
199
|
-
--layout: ${this.layout || 'row'};
|
|
200
|
-
--font-mono: ${this.monoFont || 'Monaco, "Andale Mono", "Roboto Mono", Consolas, monospace'};
|
|
201
|
-
--font-regular: ${this.regularFont || '"Open Sans", Avenir, "Segoe UI", Arial, sans-serif'};
|
|
202
|
-
--scroll-bar-width: 8px;
|
|
203
|
-
--nav-item-padding: ${this.navItemSpacing === 'relaxed'
|
|
204
|
-
? '10px 16px 10px 10px'
|
|
205
|
-
: (this.navItemSpacing === 'compact'
|
|
206
|
-
? '5px 16px 5px 10px'
|
|
207
|
-
: '7px 16px 7px 10px')};
|
|
208
|
-
|
|
209
|
-
--resp-area-height: ${this.responseAreaHeight};
|
|
210
|
-
--font-size-small: ${this.fontSize === 'default' ? '12px' : (this.fontSize === 'large' ? '13px' : '14px')};
|
|
211
|
-
--font-size-mono: ${this.fontSize === 'default' ? '13px' : (this.fontSize === 'large' ? '14px' : '15px')};
|
|
212
|
-
--font-size-regular: ${this.fontSize === 'default' ? '14px' : (this.fontSize === 'large' ? '15px' : '16px')};
|
|
213
|
-
--dialog-z-index: 1000;
|
|
214
|
-
|
|
215
|
-
--focus-shadow: 0 0 0 1px transparent, 0 0 0 3px ${newTheme.primaryColorTrans};
|
|
216
|
-
|
|
217
|
-
/* Theme specific styles */
|
|
218
|
-
--bg:${newTheme.bg1};
|
|
219
|
-
--bg2:${newTheme.bg2};
|
|
220
|
-
--bg3:${newTheme.bg3};
|
|
221
|
-
--light-bg:${newTheme.lightBg};
|
|
222
|
-
--fg:${newTheme.fg1};
|
|
223
|
-
--fg2:${newTheme.fg2};
|
|
224
|
-
--fg3:${newTheme.fg3};
|
|
225
|
-
--light-fg:${newTheme.lightFg};
|
|
226
|
-
--selection-bg:${newTheme.selectionBg};
|
|
227
|
-
--selection-fg:${newTheme.selectionFg};
|
|
228
|
-
--overlay-bg:${newTheme.overlayBg};
|
|
229
|
-
|
|
230
|
-
/* Border Colors */
|
|
231
|
-
--border-color:${newTheme.borderColor};
|
|
232
|
-
--light-border-color:${newTheme.lightBorderColor};
|
|
233
|
-
--code-border-color:${newTheme.codeBorderColor};
|
|
234
|
-
|
|
235
|
-
--input-bg:${newTheme.inputBg};
|
|
236
|
-
--placeholder-color:${newTheme.placeHolder};
|
|
237
|
-
--hover-color:${newTheme.hoverColor};
|
|
238
|
-
--red:${newTheme.red};
|
|
239
|
-
--light-red:${newTheme.lightRed};
|
|
240
|
-
--pink:${newTheme.pink};
|
|
241
|
-
--light-pink:${newTheme.lightPink};
|
|
242
|
-
--green:${newTheme.green};
|
|
243
|
-
--light-green:${newTheme.lightGreen};
|
|
244
|
-
--blue:${newTheme.blue};
|
|
245
|
-
--light-blue:${newTheme.lightBlue};
|
|
246
|
-
--orange:${newTheme.orange};
|
|
247
|
-
--light-orange:${newTheme.lightOrange};
|
|
248
|
-
--yellow:${newTheme.yellow};
|
|
249
|
-
--light-yellow:${newTheme.lightYellow};
|
|
250
|
-
--purple:${newTheme.purple};
|
|
251
|
-
--brown:${newTheme.brown};
|
|
252
|
-
|
|
253
|
-
/* Header Color */
|
|
254
|
-
--header-bg:${newTheme.headerColor};
|
|
255
|
-
--header-fg:${newTheme.headerColorInvert};
|
|
256
|
-
--header-color-darker:${newTheme.headerColorDarker};
|
|
257
|
-
--header-color-border:${newTheme.headerColorBorder};
|
|
258
|
-
|
|
259
|
-
/* Nav Colors */
|
|
260
|
-
--nav-bg-color:${newTheme.navBgColor};
|
|
261
|
-
--nav-text-color:${newTheme.navTextColor};
|
|
262
|
-
--nav-hover-bg-color:${newTheme.navHoverBgColor};
|
|
263
|
-
--nav-hover-text-color:${newTheme.navHoverTextColor};
|
|
264
|
-
--nav-accent-color:${newTheme.navAccentColor};
|
|
265
|
-
--nav-accent-text-color:${newTheme.navAccentTextColor};
|
|
266
|
-
|
|
267
|
-
/* Nav API Method Colors*/
|
|
268
|
-
--nav-get-color:${newTheme.blue};
|
|
269
|
-
--nav-put-color:${newTheme.orange};
|
|
270
|
-
--nav-post-color:${newTheme.green};
|
|
271
|
-
--nav-delete-color:${newTheme.red};
|
|
272
|
-
--nav-head-color:${newTheme.yellow};
|
|
273
|
-
|
|
274
|
-
/* Primary Colors */
|
|
275
|
-
--primary-color:${newTheme.primaryColor};
|
|
276
|
-
--primary-color-invert:${newTheme.primaryColorInvert};
|
|
277
|
-
--primary-color-trans:${newTheme.primaryColorTrans};
|
|
278
|
-
|
|
279
|
-
/*Code Syntax Color*/
|
|
280
|
-
--code-bg:${newTheme.codeBg};
|
|
281
|
-
--code-fg:${newTheme.codeFg};
|
|
282
|
-
--inline-code-fg:${newTheme.inlineCodeFg};
|
|
283
|
-
--code-property-color:${newTheme.codePropertyColor};
|
|
284
|
-
--code-keyword-color:${newTheme.codeKeywordColor};
|
|
285
|
-
--code-operator-color:${newTheme.codeOperatorColor};
|
|
286
|
-
}
|
|
287
|
-
</style>`;
|
|
288
|
-
}
|
package/webpack.config.js
DELETED
|
@@ -1,142 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
import { webpack } from 'webpack';
|
|
3
|
-
import FileManagerPlugin from 'filemanager-webpack-plugin';
|
|
4
|
-
import BundleAnalyzerPlugin from 'webpack-bundle-analyzer';
|
|
5
|
-
import CompressionPlugin from 'compression-webpack-plugin';
|
|
6
|
-
import { DuplicatesPlugin } from 'inspectpack/plugin';
|
|
7
|
-
import { CleanWebpackPlugin } from 'clean-webpack-plugin';
|
|
8
|
-
import HtmlWebpackPlugin from 'html-webpack-plugin';
|
|
9
|
-
import 'path';
|
|
10
|
-
// import ESLintPlugin from 'eslint-webpack-plugin';
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
const webpack = require('webpack');
|
|
14
|
-
const FileManagerPlugin = require('filemanager-webpack-plugin');
|
|
15
|
-
const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer');
|
|
16
|
-
const CompressionPlugin = require('compression-webpack-plugin');
|
|
17
|
-
const { DuplicatesPlugin } = require('inspectpack/plugin');
|
|
18
|
-
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
|
|
19
|
-
const HtmlWebpackPlugin = require('html-webpack-plugin');
|
|
20
|
-
const TerserPlugin = require('terser-webpack-plugin');
|
|
21
|
-
const UnminifiedWebpackPlugin = require('unminified-webpack-plugin');
|
|
22
|
-
const path = require('path');
|
|
23
|
-
const ESLintPlugin = require('eslint-webpack-plugin');
|
|
24
|
-
|
|
25
|
-
const rapidocVersion = JSON.stringify(require('./package.json').version).replace(/"/g, '');
|
|
26
|
-
|
|
27
|
-
const rapidocBanner = `
|
|
28
|
-
/**
|
|
29
|
-
* @preserve
|
|
30
|
-
* RapiDoc ${rapidocVersion.replace()} - WebComponent to View OpenAPI docs
|
|
31
|
-
* License: MIT
|
|
32
|
-
* Repo : https://github.com/rapi-doc/RapiDoc
|
|
33
|
-
* Author : Mrinmoy Majumdar
|
|
34
|
-
*/
|
|
35
|
-
`;
|
|
36
|
-
|
|
37
|
-
const commonPlugins = [
|
|
38
|
-
new webpack.ProvidePlugin({ Buffer: ['buffer', 'Buffer'] }),
|
|
39
|
-
new webpack.HotModuleReplacementPlugin(),
|
|
40
|
-
new ESLintPlugin({ extensions: ['js'] }),
|
|
41
|
-
new CleanWebpackPlugin(),
|
|
42
|
-
new webpack.optimize.LimitChunkCountPlugin({ maxChunks: 1 }),
|
|
43
|
-
new HtmlWebpackPlugin({ template: 'index.html' }),
|
|
44
|
-
new CompressionPlugin(),
|
|
45
|
-
new FileManagerPlugin({
|
|
46
|
-
events: {
|
|
47
|
-
onEnd: {
|
|
48
|
-
copy: [
|
|
49
|
-
{ source: 'dist/*.js', destination: 'docs' },
|
|
50
|
-
{ source: 'dist/*.woff2', destination: 'docs' },
|
|
51
|
-
],
|
|
52
|
-
},
|
|
53
|
-
},
|
|
54
|
-
}),
|
|
55
|
-
];
|
|
56
|
-
|
|
57
|
-
if (process.env.NODE_ENV === 'production') {
|
|
58
|
-
console.log('BUILDING FOR PRODUCTION ... '); // eslint-disable-line no-console
|
|
59
|
-
commonPlugins.push(new BundleAnalyzerPlugin({ analyzerMode: 'static' }));
|
|
60
|
-
commonPlugins.push(new DuplicatesPlugin({ emitErrors: false, verbose: true }));
|
|
61
|
-
commonPlugins.push(new UnminifiedWebpackPlugin());
|
|
62
|
-
commonPlugins.push(new webpack.BannerPlugin({
|
|
63
|
-
raw: true,
|
|
64
|
-
banner: rapidocBanner,
|
|
65
|
-
}));
|
|
66
|
-
// commonPlugins.push(new webpack.DefinePlugin({ VERSION }));
|
|
67
|
-
commonPlugins.push(new FileManagerPlugin({
|
|
68
|
-
events: {
|
|
69
|
-
onEnd: {
|
|
70
|
-
copy: [
|
|
71
|
-
{ source: 'dist/*.js', destination: 'docs' },
|
|
72
|
-
],
|
|
73
|
-
},
|
|
74
|
-
},
|
|
75
|
-
}));
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
module.exports = {
|
|
79
|
-
mode: 'production',
|
|
80
|
-
entry: './src/index.js',
|
|
81
|
-
devtool: 'cheap-module-source-map',
|
|
82
|
-
output: {
|
|
83
|
-
path: path.join(__dirname, 'dist'),
|
|
84
|
-
filename: 'rapidoc-min.js',
|
|
85
|
-
publicPath: '',
|
|
86
|
-
},
|
|
87
|
-
optimization: {
|
|
88
|
-
minimizer: [
|
|
89
|
-
new TerserPlugin({
|
|
90
|
-
extractComments: {
|
|
91
|
-
condition: /^\**!|@preserve|@license|@cc_on/i,
|
|
92
|
-
banner: (licenseFile) => `RapiDoc ${rapidocVersion} | Author - Mrinmoy Majumdar | License information can be found in ${licenseFile} `,
|
|
93
|
-
},
|
|
94
|
-
}),
|
|
95
|
-
],
|
|
96
|
-
},
|
|
97
|
-
devServer: {
|
|
98
|
-
static: {
|
|
99
|
-
directory: path.resolve(__dirname, 'docs'),
|
|
100
|
-
},
|
|
101
|
-
port: 8080,
|
|
102
|
-
hot: 'only',
|
|
103
|
-
},
|
|
104
|
-
module: {
|
|
105
|
-
rules: [
|
|
106
|
-
{
|
|
107
|
-
test: /\.js$/,
|
|
108
|
-
exclude: /node_modules/,
|
|
109
|
-
use: [
|
|
110
|
-
{ loader: 'babel-loader' },
|
|
111
|
-
],
|
|
112
|
-
},
|
|
113
|
-
{
|
|
114
|
-
test: /\.css$/,
|
|
115
|
-
use: [
|
|
116
|
-
{ loader: 'style-loader' }, // creates style nodes in HTML from CommonJS strings
|
|
117
|
-
{ loader: 'css-loader' }, // translates CSS into CommonJS
|
|
118
|
-
],
|
|
119
|
-
},
|
|
120
|
-
{
|
|
121
|
-
test: /\.(woff|woff2|eot|ttf|otf)$/,
|
|
122
|
-
use: [{
|
|
123
|
-
loader: 'file-loader',
|
|
124
|
-
options: {
|
|
125
|
-
name: '[name].[ext]',
|
|
126
|
-
},
|
|
127
|
-
}],
|
|
128
|
-
},
|
|
129
|
-
],
|
|
130
|
-
},
|
|
131
|
-
resolve: {
|
|
132
|
-
fallback: {
|
|
133
|
-
fs: false,
|
|
134
|
-
buffer: require.resolve('buffer'),
|
|
135
|
-
},
|
|
136
|
-
alias: {
|
|
137
|
-
'~': path.resolve(__dirname, 'src'),
|
|
138
|
-
'lit-html/lib/shady-render.js': path.resolve(__dirname, './node_modules/lit-html/lit-html.js'), // removes shady-render.js from the bundle
|
|
139
|
-
},
|
|
140
|
-
},
|
|
141
|
-
plugins: commonPlugins,
|
|
142
|
-
};
|