forked from Apicurio/api-designer-poc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.dev.js
70 lines (64 loc) · 2.19 KB
/
webpack.dev.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
65
66
67
68
69
70
/* eslint-disable @typescript-eslint/no-var-requires */
const { merge } = require("webpack-merge");
const common = require("./webpack.common.js");
const CopyPlugin = require("copy-webpack-plugin");
const webpack = require("webpack");
if (!process.env.API_DESIGNER_POC_CONFIG) {
console.info("");
console.info("=======================================================================");
console.info("Using default 'none' configuration for running on localhost.");
console.info("You can configure a profile using the API_DESIGNER_POC_CONFIG env var.");
console.info("Example: 'export API_DESIGNER_POC_CONFIG=staging'");
console.info("=======================================================================");
console.info("");
}
const CONFIG = process.env.API_DESIGNER_POC_CONFIG || "none";
console.info("Using API Designer POC config: ", CONFIG);
const devServerConfigFile = `./configs/${CONFIG}/devServer.json`;
const devServerConfig = require(devServerConfigFile);
let filesToCopy = [
{ from: `./configs/${CONFIG}/config.js`, to: "config.js"}
];
if (devServerConfig.keycloak) {
filesToCopy.push(
{ from: "./src/keycloak.dev.json", to: "keycloak.json"}
);
}
if (devServerConfig.warning) {
console.info("");
console.info("====================================================================");
console.info(devServerConfig.warning);
console.info("====================================================================");
console.info("");
}
module.exports = merge(common("development"), {
mode: "development",
devtool: "eval-source-map",
devServer: {
static: {
directory: "./dist",
},
host: devServerConfig.host,
port: devServerConfig.port,
compress: true,
//inline: true,
historyApiFallback: true,
allowedHosts: "all",
hot: true,
client: {
overlay: true,
},
open: true,
https: devServerConfig.protocol === "https",
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",
},
},
plugins: [
new CopyPlugin({
patterns: filesToCopy
})
]
});