-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
36 lines (34 loc) · 899 Bytes
/
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
/* eslint-disable @typescript-eslint/no-var-requires */
// development server for the app project
// run with: npm start
const browserSync = require('browser-sync').create()
const historyApiFallback = require('connect-history-api-fallback')
const logger = require('connect-logger')
const compression = require('compression')
const zlib = require('zlib')
require('dotenv').config()
browserSync.init({
cwd: 'public',
server: {
baseDir: 'public',
index: 'index.html',
routes: {
'/src': './src/',
},
},
files: ['scripts/**', 'index.html'],
middleware: [
logger(),
compression({ level: zlib.constants.Z_BEST_COMPRESSION }),
historyApiFallback(),
],
rewriteRules: [
{
match: /\$\{([A-Za-z0-9_]+)\}/g,
fn: function (req, res, match) {
const varName = match.substring(2, match.length - 1)
return varName in process.env ? process.env[varName] : ''
},
},
],
})