Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
gitpod-io
GitHub Repository: gitpod-io/gitpod
Path: blob/main/components/dashboard/craco.config.js
3604 views
1
/**
2
* Copyright (c) 2021 Gitpod GmbH. All rights reserved.
3
* Licensed under the GNU Affero General Public License (AGPL).
4
* See License.AGPL.txt in the project root for license information.
5
*/
6
const { when } = require("@craco/craco");
7
const path = require("path");
8
const webpack = require("webpack");
9
10
function withEndingSlash(str) {
11
return str.endsWith("/") ? str : str + "/";
12
}
13
14
module.exports = {
15
style: {
16
postcss: {
17
mode: "file",
18
},
19
},
20
eslint: {
21
mode: "file",
22
},
23
webpack: {
24
configure: {
25
resolve: {
26
alias: {
27
"@podkit": path.resolve(__dirname, "./src/components/podkit/"),
28
},
29
fallback: {
30
crypto: require.resolve("crypto-browserify"),
31
stream: require.resolve("stream-browserify"),
32
url: require.resolve("url"),
33
util: require.resolve("util"),
34
net: false,
35
path: false,
36
fs: false,
37
os: false,
38
},
39
},
40
module: {
41
rules: [
42
{
43
test: /\.m?js$/,
44
resolve: {
45
fullySpecified: false,
46
},
47
},
48
{
49
// Import HTML files as raw strings (for minimal-login.html)
50
test: /minimal-login\.html$/,
51
type: "asset/source",
52
},
53
],
54
},
55
plugins: [
56
new webpack.ProvidePlugin({
57
process: "process/browser",
58
Buffer: ["buffer", "Buffer"],
59
}),
60
],
61
// If ASSET_PATH is set, we imply that we also want a statically named main.js, so we can reference it from the outside
62
output: !!process.env.ASSET_PATH
63
? {
64
...(webpack?.configure?.output || {}),
65
filename: (pathData) => {
66
return pathData.chunk.name === "main" ? "static/js/main.js" : undefined;
67
},
68
publicPath: withEndingSlash(process.env.ASSET_PATH),
69
}
70
: undefined,
71
},
72
},
73
devServer: {
74
client: {
75
webSocketURL: {
76
hostname: process.env.HMR_HOST ? new URL(process.env.HMR_HOST).hostname : "localhost",
77
port: process.env.HMR_HOST ? 443 : 3001,
78
protocol: "wss",
79
},
80
},
81
},
82
...when(process.env.GP_DEV_HOST && process.env.GP_DEV_COOKIE, () => ({
83
devServer: {
84
proxy: {
85
"/api": {
86
target: "https://" + process.env.GP_DEV_HOST,
87
ws: true,
88
headers: {
89
host: process.env.GP_DEV_HOST,
90
origin: "https://" + process.env.GP_DEV_HOST,
91
cookie: process.env.GP_DEV_COOKIE,
92
},
93
},
94
},
95
},
96
})),
97
};
98
99