-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.js
54 lines (47 loc) · 1.29 KB
/
index.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
"use strict";
const WebpackConfigHelpers = require("razzle-dev-utils/WebpackConfigHelpers");
const Helpers = new WebpackConfigHelpers(process.cwd());
const defaultOptions = {
svgr: {
dev: {
svgoConfig: {
plugins: [{ removeViewBox: false }, { mergePaths: false }, { removeTitle: false }],
},
},
prod: {
svgoConfig: {
plugins: [{ removeViewBox: false }, { mergePaths: false }, { removeTitle: false }],
},
},
},
};
module.exports = {
modifyWebpackConfig({
env: { target, dev },
webpackConfig,
options: {
pluginOptions, // the options passed to the plugin ({ name:'pluginname', options: { key: 'value'}})
},
}) {
const config = Object.assign({}, webpackConfig);
const options = Object.assign({}, defaultOptions, pluginOptions);
// Exclude from file-loader
config.module.rules[config.module.rules.findIndex(Helpers.makeLoaderFinder("file-loader"))].exclude.push(
/\.(svg)$/
);
const constantEnv = dev ? "dev" : "prod";
config.module.rules = [
...config.module.rules,
{
test: /\.svg$/,
use: [
{
loader: require.resolve("@svgr/webpack"),
options: options.svgr[constantEnv],
},
],
},
];
return config;
},
};