https://github.com/viktorlarsson/gulp-inject-svg
This gulp plugin will check all img tags with an external svg and replace the tag with inline svg.
https://github.com/viktorlarsson/gulp-inject-svg
gulp inline svg
Last synced: 10 months ago
JSON representation
This gulp plugin will check all img tags with an external svg and replace the tag with inline svg.
- Host: GitHub
- URL: https://github.com/viktorlarsson/gulp-inject-svg
- Owner: viktorlarsson
- License: bsd-3-clause
- Created: 2016-03-02T13:01:57.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2020-10-25T14:50:22.000Z (over 5 years ago)
- Last Synced: 2025-07-24T17:30:06.121Z (11 months ago)
- Topics: gulp, inline, svg
- Language: JavaScript
- Homepage:
- Size: 28.3 KB
- Stars: 19
- Watchers: 2
- Forks: 12
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.md
Awesome Lists containing this project
README
# gulp-inject-svg
[](http://github.com/badges/stability-badges)
## Information
This gulp plugin will check all img tags with an external svg and replace the tag with inline svg.
[](https://nodei.co/npm/gulp-inject-svg/)
## Usage
```html
```
#### Note
You either need to use an absolute path relative to your project root
`/src/assets/img/icons/exclamation_mark.svg`
or pass a configuration object to the plugin
`injectSvg({ base: '/src' })`
#### Ignore some SVG files
You can prevent some SVG files from inject by the attribute `data-skip-inject-svg`
```html
```
#### Example
```javascript
var gulp = require('gulp');
var injectSvg = require('gulp-inject-svg');
var injectSvgOptions = { base: '/src' };
gulp.task('injectSvg', function() {
return gulp.src('/src/**/*.html')
.pipe(injectSvg(injectSvgOptions))
.pipe(gulp.dest('public/'));
});
```
Replaces your <img> tags with the corresponding inlined svg file.
```html
```