-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathgatsby-node.js
More file actions
81 lines (75 loc) · 2.49 KB
/
gatsby-node.js
File metadata and controls
81 lines (75 loc) · 2.49 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
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
/**
* Implement Gatsby's Node APIs in this file.
*
* See: https://www.gatsbyjs.org/docs/node-apis/
*/
// eslint-disable-next-line @typescript-eslint/no-var-requires
const path = require("path")
// eslint-disable-next-line @typescript-eslint/no-var-requires
const sharp = require("sharp")
// eslint-disable-next-line @typescript-eslint/no-var-requires
const webpack = require("webpack")
sharp.cache(false)
sharp.simd(false)
// You can delete this file if you're not using it
exports.onCreateWebpackConfig = ({ actions, stage }) => {
const config = {
plugins: [
new webpack.NormalModuleReplacementPlugin(/node:/, (resource) => {
resource.request = resource.request.replace(/^node:/, "")
}),
],
resolve: {
fallback: {
assert: false,
crypto: false,
http: false,
https: false,
os: false,
stream: false,
util: false,
url: false,
path: false,
diagnostics_channel: false,
},
alias: {
// Fix ua-parser-js@2.x ESM syntax bug - force CJS files
// The .mjs files have invalid import syntax: { name: alias } instead of { name as alias }
"ua-parser-js/helpers": path.join(
__dirname,
"node_modules/ua-parser-js/src/helpers/ua-parser-helpers.js"
),
"ua-parser-js/device-detection": path.join(
__dirname,
"node_modules/ua-parser-js/src/device-detection/device-detection.js"
),
"ua-parser-js/bot-detection": path.join(
__dirname,
"node_modules/ua-parser-js/src/bot-detection/bot-detection.js"
),
"ua-parser-js/browser-detection": path.join(
__dirname,
"node_modules/ua-parser-js/src/browser-detection/browser-detection.js"
),
"ua-parser-js/extensions": path.join(
__dirname,
"node_modules/ua-parser-js/src/extensions/ua-parser-extensions.js"
),
"ua-parser-js/enums": path.join(
__dirname,
"node_modules/ua-parser-js/src/enums/ua-parser-enums.js"
),
},
},
}
// During SSR, replace WearablePreview with a dummy module to avoid window access
if (stage === "build-html" || stage === "develop-html") {
config.plugins.push(
new webpack.NormalModuleReplacementPlugin(
/decentraland-ui2\/dist\/components\/WearablePreview\/WearablePreview/,
require.resolve("./src/utils/wearable-preview-ssr-stub.js")
)
)
}
actions.setWebpackConfig(config)
}