-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig-overrides.js
71 lines (67 loc) · 1.81 KB
/
config-overrides.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
/*
* Customize create-react-app's Webpack configurating using react-app-rewired.
* See: https://github.com/timarney/react-app-rewired
*
* @flow strict
*/
const path = require("path")
const traverse = require("traverse")
module.exports = {
webpack(config /*: Object */, env /*: Object */) {
traverse(config).forEach(function(node) {
// Apply Babel transformations to @salesforce/design-system-react
if (
node &&
typeof node.loader === "string" &&
node.loader.match(/babel-loader/)
) {
this.update({
...node,
include: [
path.join(__dirname, "node_modules/@salesforce/design-system-react")
].concat(node.include)
})
}
// @salesforce-ux/design-system provides several assets with the
// same name, `symbols.svg`, which leads to a name conflict in the
// Webpack file-loader configuration. This modifies the file-loader
// configuration to incorporate the path to a resource in generated
// file names, as opposed to basing generated names solely on the
// basename of the asset.
if (
node &&
typeof node.name === "string" &&
node.name.match(/static\/media\//)
) {
this.update({
...node,
name: "static/media/[path][name].[hash:8].[ext]"
})
}
})
// Add expose-loader to expose jQuery so
// jquery-ui-touch-punch can find the jQuery global
config.module.rules.push({
test: require.resolve("jquery"),
use: [
{
loader: "expose-loader",
options: "$"
},
{
loader: "expose-loader",
options: "jQuery"
}
]
})
return config
},
jest(config /*: Object */) {
config.transformIgnorePatterns = [
// Apply Babel transformations to @salesforce dependencies, but not
// to other node modules.
"[/\\\\]node_modules[/\\\\](?!@salesforce[/\\\\]).+\\.(js|jsx|mjs)$"
]
return config
}
}