gulp-inline-source
gulp-inline-source copied to clipboard
Cannot pipe after gulp-jade
I have a simple testing folder:
./
a.js
gulpfile.js
test.jade
a.js
console.log('Hello!');
gulpfile.js
var gulp = require('gulp');
var jade = require('gulp-jade');
var inlineSouce = require('gulp-inline-source');
gulp.task('default', function() {
return gulp.src('*.jade')
.pipe(jade())
.pipe(inlineSouce())
.pipe(gulp.dest('.'));
});
test.jade
doctype html
html
head
script(scr="a.js", inline)
However after running gulp
, the output test.html
doesn't include a.js
inline as expected:
<!DOCTYPE html><html><head><script scr="a.js" inline></script></head></html>
I can confirm this happening. The paths to inlined sources are messed up after the jade pipe. I wasn't able to fix it with rootpath
option.
+1
I will take a look this weekend.
Any progress on this issue?
+1
Hi rhere I know this is a old post, hope someone can chip in or has resolved this?
I am having a similar problem with .nunjucks files using gulp-nunjucks-render
gulpfile.js
pipe(nunjucksRender({ path: njkPaths, ext: "", data: ENV_VARS, envOptions: { trimBlocks: true, lstripBlocks: true } })) .pipe(inlineSource({ compress: false, saveRemote: true, handlers: [require("./nunjucksHandler.js")] }))
nunjucksHandler.js ?
const Nunjucks = require('nunjucks'); module.exports = function nunjucks(source, context) { return new Promise((resolve, reject) => { if ( source.fileContent && !source.content && source.type == "text/css" ) { let content; try { content = Nunjucks.precompile(source.fileContent); } catch (err) { return reject(err); } // Need to expose templates for later use somehow... source.content = content } resolve(); }); };
I was trying the precompile approach https://github.com/popeindustries/inline-source/issues/70#issuecomment-384548345 but got nowhere.
Thanks