electron-userland / electron-userland/electron-webpack

Unable to Import svg as React Component

Open
#421 7 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
902
Forks
168
PR merge metrics
No merged PRs in 30d

Description

* **electron-builder Version**: 22.9.1
* **electron-webpack Version**: 2.8.2

* **Target**: Windows, Mac

I'm trying to import a SVG as a React Component.

```js
import { ReactComponent as Icon} from "../assets/icon.svg";
```

When i try to do this, i get errors like this.
![image](https://user-images.githubusercontent.com/54715823/104351984-648c1980-5506-11eb-9900-a36135969b89.png)

I've tried using svgr without any luck.

webpack.main.additions.js
```js
module.exports = (config) => {
return {
...config,
devtool: false,
module: {
rules: [
{
test: /\.ts$/,
loader: "ts-loader",
},
{
test: /\.html$/,
use: "html-loader",
},
{
test: /\.svg$/,
use: ["@svgr/webpack"],
},
],
},
};
};
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.