Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
gitpod-io
GitHub Repository: gitpod-io/gitpod
Path: blob/main/components/dashboard/craco.config.js
2492 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
},
50
plugins: [
51
new webpack.ProvidePlugin({
52
process: "process/browser",
53
Buffer: ["buffer", "Buffer"],
54
}),
55
],
56
// If ASSET_PATH is set, we imply that we also want a statically named main.js, so we can reference it from the outside
57
output: !!process.env.ASSET_PATH
58
? {
59
...(webpack?.configure?.output || {}),
60
filename: (pathData) => {
61
return pathData.chunk.name === "main" ? "static/js/main.js" : undefined;
62
},
63
publicPath: withEndingSlash(process.env.ASSET_PATH),
64
}
65
: undefined,
66
},
67
},
68
devServer: {
69
client: {
70
webSocketURL: {
71
hostname: process.env.HMR_HOST ? new URL(process.env.HMR_HOST).hostname : "localhost",
72
port: process.env.HMR_HOST ? 443 : 3001,
73
protocol: "wss",
74
},
75
},
76
},
77
...when(process.env.GP_DEV_HOST && process.env.GP_DEV_COOKIE, () => ({
78
devServer: {
79
proxy: {
80
"/api": {
81
target: "https://" + process.env.GP_DEV_HOST,
82
ws: true,
83
headers: {
84
host: process.env.GP_DEV_HOST,
85
origin: "https://" + process.env.GP_DEV_HOST,
86
cookie: process.env.GP_DEV_COOKIE,
87
},
88
},
89
},
90
},
91
})),
92
};
93
94