/
server.js
52 lines (49 loc) · 1.15 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
50
51
52
import { create } from 'browser-sync';
const bsServer = create();
const docsConfig = {
files: ['./dist/**/*.*', './docs/**/*.*'],
port: 3000,
ghostMode: {
clicks: false,
forms: false,
scroll: false,
},
open: false,
notify: false,
cors: true,
reloadDebounce: 1000,
reloadOnRestart: true,
server: {
baseDir: ['./docs/'],
routes: {
'/CHANGELOG.md': './CHANGELOG.md',
'/dist': './dist',
},
},
};
const playwrightConfig = {
...docsConfig,
port: 4000,
server: {
...docsConfig.server,
middleware: [
// Blank page required for test environment
{
route: '/_blank.html',
handle(req, res, next) {
res.setHeader('Content-Type', 'text/html');
res.end('');
next();
},
},
],
},
snippet: false,
watch: false,
};
const args = process.argv.slice(2);
const config = args.includes('--playwright') ? playwrightConfig : docsConfig;
const configName = config === playwrightConfig ? 'playwright' : 'demo';
// eslint-disable-next-line no-console
console.log(`\nStarting ${configName} server on port ${config.port}\n`);
bsServer.init(config);