Comments (6)
Hey,
sure thing.
You can use https://github.com/webpack/file-loader and loader to web pack config
{ test: /\.(png|jpg|svg)$/, loader: 'file?name=/[name]-[hash].[ext]' }
from react.
Give me second, I'll prepare you a demo
from react.
Checkout git diff here: https://github.com/werein/react/compare/feature/images
from react.
Thanks Jiri. Your instructions are crystal clear but I get this error:
Module parse failed: /Users/davidhandel/code/idr/src/public/images/logo.png Line 1: Unexpected token ILLEGAL
You may need an appropriate loader to handle this file type.
(Source code omitted for this binary file)
@ ./src/components/LoggedInHeader.js 31:12-48
I have a png file loaded in logo.png. I have placed your loader in my webpack.development.js. All I see is a broken image in the browser.
from react.
It says that you need a loader which I forgot to save in packages.json
npm i file-loader --save
from react.
For whatever reason, the loader code didn't work for me in Webpack config but when I used it in the component like this:
const logo = require('file?name=/images/[name]-[hash].[ext]!../public/images/logo.png');
I could successfully render the logo with an img tag with src={logo} ,
Many thanks.
from react.
Related Issues (11)
- React transform is not available due to Babel version
- nothing on screen HOT 1
- Windows support HOT 1
- Use enzyme for testing
- Deploying to Heroku HOT 3
- After the project build, run index.html to display the blank interface. HOT 14
- Hanging Webpack Build
- Api proxy doesn't seem to be working for me
- ESLINT requires node5 HOT 1
- Module build failed: ModuleBuildError: Module build failed: Error: Node Sass does not yet support your current environment: OS X 64-bit with Unsupported runtime (64) For more information on which environments are supported please see: HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react.