Inline css and js links with file contents
npm install gulp-smoosherInstall with npm
```
npm install --save-dev gulp-smoosher
`html`
...
`css`
body {
background: red;
}
`js
var gulp = require('gulp');
var smoosher = require('gulp-smoosher');
gulp.task('default', function () {
gulp.src('index.html')
.pipe(smoosher())
.pipe(gulp.dest('dist'));
});
`
`html`
...
`js
var gulp = require('gulp');
var smoosher = require('gulp-smoosher');
gulp.task('default', function () {
gulp.src('index.html')
.pipe(smoosher({
cssTags: {
begin: '
end: '
},
jsTags: {
begin: '
end: '
}
}))
.pipe(gulp.dest('dist'));
});
`
will result in the following:
`html`
background: red;
}
...index.html$3
Say your is still in your src/ directory and files you intend to smoosh are already written to your dist/. In this case, specify a custom base to resolve your files from.
`js`
gulp.task('default', ['minifyCss', 'uglifyJs'], function () {
gulp.src('src/index.html')
.pipe(smoosher({
base: 'dist'
}))
.pipe(gulp.dest('dist'));
});
is true the plugin will keep running even if it finds a nonexistent file:`js
gulp.task('default', function () {
gulp.src('src/index.html')
.pipe(smoosher({
ignoreFilesNotFound: true
}))
.pipe(gulp.dest('dist'));
});
``If you use grunt instead of gulp, but want to perform a similar task, use grunt-html-smoosher.
- Gabriel Florit
- Andrew Shaffer
- Jackson Ray Hamilton
MIT © Gabriel Florit