forked from trufflesuite/ganache-ui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.renderer.js
77 lines (70 loc) · 1.65 KB
/
webpack.renderer.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
const path = require("path");
const babelLoader = {
loader: "babel-loader",
options: {
cacheDirectory: true,
cacheCompression: false
}
};
module.exports = function(config) {
const rootDir = path.resolve(__dirname, "../");
const srcDir = path.resolve(rootDir, "src")
const rules = config.module.rules;
// we don't want to url-encode svgs, so remove the svgs from the image rule
const imageRule = rules.find(rule => {
return rule.test.toString() === "/\\.(png|jpe?g|gif|svg)(\\?.*)?$/";
});
// override its test
imageRule.test = /\.(png|jpe?g|gif)(\?.*)?$/i;
imageRule.include = [
srcDir,
path.resolve(rootDir, "static")
];
imageRule.use = [
"cache-loader",
imageRule.use
];
// add our custom rules
rules.push.apply(rules, [
{
test: /\.(js|jsx)$/i,
include: srcDir,
use: [
{
loader: "babel-loader",
options: {
...babelLoader.options,
presets: ["@babel/react"]
}
}
],
},
{
test: /\.svg$/i,
include: path.resolve(srcDir, "renderer", "icons"),
use: [
babelLoader,
{
loader: "react-svg-loader",
options: {
svgo: {
plugins: [
{
removeViewBox: false
}
]
}
}
}
]
}
]);
// Enable referencing our static assets in css/scss:
if (!config.resolve) {
config.resolve = {};
}
config.resolve.alias["@static"] = path.resolve(__dirname, '../static');
config.resolve.symlinks = false;
config.output.pathinfo = false;
return config;
};