gulp-inline-source icon indicating copy to clipboard operation
gulp-inline-source copied to clipboard

Cannot pipe after gulp-jade

Open w9 opened this issue 10 years ago • 6 comments

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>

w9 avatar Dec 04 '14 21:12 w9

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.

ghost avatar Jan 06 '15 20:01 ghost

+1

haydenbleasel avatar Jun 18 '15 15:06 haydenbleasel

I will take a look this weekend.

fmal avatar Jun 18 '15 21:06 fmal

Any progress on this issue?

sjardim avatar Sep 11 '15 16:09 sjardim

+1

alhafoudh avatar Sep 24 '15 09:09 alhafoudh

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

rrdesignweb avatar Dec 15 '22 21:12 rrdesignweb