Created
February 11, 2017 20:51
-
-
Save daviseford/dab4333bfb71a9c39cc371d0ff305605 to your computer and use it in GitHub Desktop.
Importing an image into electron-react-boilerplate
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// First, import the image like this | |
import image_src from './../img/your_image.png'; | |
// Use it inline like so (in React) | |
class YourImage extends React.Component { | |
render(){ | |
return ( | |
<img src={image_src} /> | |
) | |
} | |
} | |
// Next, add this entry into webpack.config.base.js under modules.loaders: | |
{ | |
test: /\.(png|jpg)$/, | |
loader: 'url?limit=25000' | |
} | |
// Important!!! Make sure that you disable these lines in webpack.config.production.js | |
{ | |
test: /\.(?:ico|gif|png|jpg|jpeg|webp)$/, | |
loader: 'url-loader' | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment