-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.development.js
More file actions
executable file
·56 lines (54 loc) · 1.91 KB
/
Copy pathwebpack.development.js
File metadata and controls
executable file
·56 lines (54 loc) · 1.91 KB
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
const merge = require('webpack-merge');
const config = require('./webpack.config.js');
const webpack = require('webpack');
const ndConfig = require('./webpack/ndConfig.js');
const ndConfigServiceUrl = ndConfig["process.env.ND_SERVICE_URL"];
const ndServiceUrl = (ndConfigServiceUrl&&ndConfigServiceUrl.length>0?JSON.parse(ndConfigServiceUrl):"https://canary.nativedocuments.com");
console.log("[ND] proxy to service at "+JSON.stringify(ndServiceUrl));
const CUSTOM_PATH=new RegExp("^/(...)/custom/(.*)$");
module.exports = merge(config, {
devServer: {
host: '127.0.0.1',
port: 8888,
https: false,
headers: {
"Access-Control-Allow-Origin": "*",
"Access-Control-Allow-Methods": "GET, POST, PUT, DELETE, PATCH, OPTIONS",
"Access-Control-Allow-Headers": "X-Requested-With, content-type, Authorization"
},
before: function(app) {
app.get(CUSTOM_PATH, function(req, res) {
res.redirect(req.url.replace(CUSTOM_PATH, "/custom/$2"));
});
},
"proxy": {
"/v1/": {
"target": ndServiceUrl,
"secure": false,
"changeOrigin": true,
"ws": true
},
"/w1/": {
"target": ndServiceUrl,
"secure": false,
"changeOrigin": true,
"ws": true
},
"/": {
"target": ndServiceUrl,
"secure": false,
"changeOrigin": true,
"autoRewrite": true,
"protocolRewrite": "http",
"headers": {
'X-ND-DEV-ENV': 'npm'
}
}
}
},
mode: "development",
plugins: [
new webpack.DefinePlugin(Object.assign({
'process.env.NODE_ENV': JSON.stringify("development")
}, ndConfig))]
});