-
-
Notifications
You must be signed in to change notification settings - Fork 69
/
server.js
49 lines (47 loc) · 1.28 KB
/
server.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import { create } from 'browser-sync';
import compression from 'compression';
const bsServer = create();
bsServer.init({
files: ['./dist/**/*.*', './docs/**/*.*'],
ghostMode: {
clicks: false,
forms: false,
scroll: false
},
open: false,
notify: false,
cors: true,
reloadDebounce: 1000,
reloadOnRestart: true,
server: {
baseDir: ['./docs/'],
middleware: [compression()],
routes: {
'/CHANGELOG.md': './CHANGELOG.md'
}
},
serveStatic: ['./dist/'],
rewriteRules: [
// Replace CDN URLs with local paths
{
match: /https?.*\/CHANGELOG.md/g,
replace: '/CHANGELOG.md'
},
{
// CDN versioned default
// Ex1: //cdn.com/package-name
// Ex2: http://cdn.com/[email protected]
// Ex3: https://cdn.com/package-name@latest
match: /(?:https?:)*\/\/.*cdn.*docsify-tabs[@\d.latest]*(?=["'])/g,
replace: '/docsify-tabs.js'
},
{
// CDN paths to local paths
// Ex1: //cdn.com/package-name/path/file.js => /path/file.js
// Ex2: http://cdn.com/[email protected]/dist/file.js => /dist/file.js
// Ex3: https://cdn.com/package-name@latest/dist/file.js => /dist/file.js
match: /(?:https?:)*\/\/.*cdn.*docsify-tabs[@\d.latest]*\/(?:dist\/)/g,
replace: '/'
}
]
});