-
Notifications
You must be signed in to change notification settings - Fork 3.2k
/
Copy pathwebpack.config.js
109 lines (101 loc) · 2.94 KB
/
webpack.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
"use strict;";
const MonacoWebpackPlugin = require('monaco-editor-webpack-plugin');
const CopyWebpackPlugin = require("copy-webpack-plugin");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const webpack = require("webpack");
const path = require("path");
const isProd = process.env.NODE_ENV === "production";
const proxyConf = {
target: isProd ? "" : "http://localhost:2746",
secure: false
};
console.log(`Bundling for ${isProd ? 'production' : 'development'}...`);
const config = {
mode: isProd ? "production" : "development",
entry: {
main: "./src/app/index.tsx"
},
output: {
filename: "[name].[hash].js",
path: __dirname + "/../../dist/app"
},
devtool: "source-map",
resolve: {
extensions: [".ts", ".tsx", ".js", ".json", ".ttf"]
},
module: {
rules: [
{
test: /\.tsx?$/,
loaders: [...(isProd ? [] : ["react-hot-loader/webpack"]), `ts-loader?transpileOnly=${!isProd}&allowTsInNodeModules=true&configFile=${path.resolve("./src/app/tsconfig.json")}`]
}, {
enforce: 'pre',
exclude: [
/node_modules\/react-paginate/,
/node_modules\/monaco-editor/,
],
test: /\.js$/,
loaders: [...(isProd ? ['babel-loader'] : ['source-map-loader'])],
}, {
test: /\.scss$/,
loader: "style-loader!raw-loader!sass-loader"
}, {
test: /\.css$/,
loader: "style-loader!raw-loader"
}, {
test: /\.ttf$/,
use: ['file-loader']
}
]
},
node: {
fs: "empty"
},
plugins: [
new webpack.DefinePlugin({
"process.env.NODE_ENV": JSON.stringify(process.env.NODE_ENV || "development"),
SYSTEM_INFO: JSON.stringify({
version: process.env.VERSION || "latest"
}),
"process.env.DEFAULT_TZ": JSON.stringify("UTC"),
}),
new HtmlWebpackPlugin({ template: "src/app/index.html" }),
new CopyWebpackPlugin([{
from: "node_modules/argo-ui/src/assets",
to: "assets"
}, {
from: "node_modules/@fortawesome/fontawesome-free/webfonts",
to: "assets/fonts"
}, {
from: "../api/openapi-spec/swagger.json",
to: "assets/openapi-spec/swagger.json"
}, {
from: "../api/jsonschema/schema.json",
to: "assets/jsonschema/schema.json"
}, {
from: 'node_modules/monaco-editor/min/vs/base/browser/ui/codiconLabel/codicon/codicon.ttf',
to: "."
}]),
new MonacoWebpackPlugin({ languages: ["json", "yaml"] })
],
devServer: {
// this needs to be disable to allow EventSource to work
compress: false,
historyApiFallback: {
disableDotRule: true
},
headers: {
'X-Frame-Options': 'SAMEORIGIN'
},
proxy: {
"/api/v1": proxyConf,
"/artifact-files": proxyConf,
"/artifacts": proxyConf,
"/input-artifacts": proxyConf,
"/artifacts-by-uid": proxyConf,
"/input-artifacts-by-uid": proxyConf,
"/oauth2": proxyConf,
}
}
};
module.exports = config;