fmal / gulp-inline-source

Inline flagged js & css sources.
MIT License
212 stars 31 forks source link

Cannot pipe after gulp-jade #8

Open w9 opened 9 years ago

w9 commented 9 years ago

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>
ghost commented 9 years ago

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.

haydenbleasel commented 9 years ago

+1

fmal commented 9 years ago

I will take a look this weekend.

sjardim commented 9 years ago

Any progress on this issue?

alhafoudh commented 9 years ago

+1

rrdesignweb commented 1 year ago

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