Comments (11)
If you want to use svg files, you have to add a file-loader in your webpack.dev.js
and webpack.prod.js
config files (in rules[]
) :
...
{
test: /\.svg$/,
loader: 'file-loader'
}
...
from webpack-starter-basic.
;-)
from webpack-starter-basic.
Thanks for the help @washaweb ! And sorry I couldn't look into this everyone else, stressing out over deadlines currently.
Will incorporate the solution into the README.
from webpack-starter-basic.
can you help me?
from webpack-starter-basic.
@washaweb this boilerplate use url-loader to loading images, why for svg images i need to use file-loader?
can I add svg here: test: /\.(png|jpg|gif|svg)$/
, and load with url-loader? or from file-loader is better?
from webpack-starter-basic.
How can I reference to the SVG file in the index.html after I added the loader to webpack's config files? <img src="<% require('.src/path/to/image.svg') %>">
doesn't seem to work - it outputs only an empty string.
from webpack-starter-basic.
@chrisschaetzlein either remove the '.' at the beginning of the SVG path or add a slash just after. You URL should look like this:
<%= require('./src/path/to/image.svg') %>
or:
<%= require('src/path/to/image.svg') %>
from webpack-starter-basic.
@washaweb That was a typo in my comment, sorry. I already had ./src/path/to/image.svg
. Webpack seems to find the file, it's included in the console output. Doesn't output anything to index.html though.
from webpack-starter-basic.
@UlpiusCode You could do that (using url-loader
for your svg images), but doing so, SVG code would be converted in a base64 encoded image.
That is not a really a good thing if you intend to later modify your SVG code with CSS or JavaScript interactions.
from webpack-starter-basic.
@chrisschaetzlein do you place this code in a <img src="">
tag ?
from webpack-starter-basic.
@washaweb jeez, I started the include in the .html file with <% require
instead of <%= require
... sorry! It works with the latter, obviously 🙄
from webpack-starter-basic.
Related Issues (20)
- Update needed : optionsSchema.definitions.output.properties.path.description, HOT 2
- node fs missing? HOT 1
- problem with babel-preset-flow HOT 3
- kickstart throws error 130 HOT 3
- How to include JS libraries HOT 4
- Could you add stylelint? HOT 2
- .
- Static assets and fonts HOT 4
- . HOT 2
- Adding background form scss doesn't work HOT 5
- favicons-webpack-plugin -> webapp-webpack-plugin HOT 1
- service worker generation? HOT 2
- Adding more pages HOT 2
- Can't include the one HTML template inside another one. HOT 2
- *-close classes were removed from build HOT 1
- Upgrade to webpack 4 HOT 1
- Allow for hot module reloading setup on kickstart
- Investigate mini-css-extract-plugin as a replacement for ExtractTextPlugin HOT 1
- Add a config to change which CSS-Pre-Processor 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 webpack-starter-basic.