Skip to content

Instantly share code, notes, and snippets.

@daviseford
Created February 11, 2017 20:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save daviseford/dab4333bfb71a9c39cc371d0ff305605 to your computer and use it in GitHub Desktop.
Save daviseford/dab4333bfb71a9c39cc371d0ff305605 to your computer and use it in GitHub Desktop.
Importing an image into electron-react-boilerplate
// 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