-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack-devserver.config.js
64 lines (61 loc) · 1.38 KB
/
webpack-devserver.config.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
53
54
55
56
57
58
59
60
61
62
63
64
var path = require('path')
var config = require ('./config')
var user = require('./demo/demo_user.json')
var { createSignedUrl, accessToken } = require('./server_utils/auth_utils')
var webpackConfig = {
mode: 'development',
entry: {
demo: './demo/demo.ts'
},
output: {
filename: "[name].js",
path: path.join(__dirname, "demo")
},
node: {
fs: 'empty',
net: 'empty',
tls: 'empty'
},
resolve: {
extensions: [".ts", ".js"],
alias: {
config: path.join(__dirname, './config.js'),
}
},
module: {
rules: [
{
test: /\.ts$/,
loader: "ts-loader",
options: {
compilerOptions: {
declaration: false
}
}
}
]
},
devServer: {
compress: true,
contentBase: [
path.join(__dirname, "demo")
],
host: config.demo_host,
port: config.demo_port,
https: true,
watchContentBase: true,
before: (app) => {
app.get('/auth', function(req, res) {
// Authenticate the request is from a valid user here
const src = req.query.src;
const url = createSignedUrl(src, user, config.host, config.secret);
res.json({ url });
});
app.get('/token', async function(req, res) {
const token = await accessToken(user.external_user_id);
res.json( token );
});
}
}
}
module.exports = webpackConfig