klei/gulp-inject

atomic deployment issue

artemartemov opened this issue · 3 comments

Hey there,

Having some trouble trying to figure out how to get gulp-inject work during my CI build steps. Everything works as intended locally, but when deploybot runs my gulp step, the injection source string is blank.

<!-- inject:css -->
    <link rel="stylesheet" href="">
<!-- endinject -->

I have tried various options with no luck, my assumption is that since the build step is done in a separate container it doesn't "know" the actual path to inject, but I am not sure as all the other build steps are totally working fine - and also works fine on my local.

here is my gulpfile.js inject step - all my dependencies are in my package.json file. there are no errors in the log during the build steps.

var injectTarget = gulp.src( './templates/partials/base.html.twig' );

gulp.task('stage-inject', function() {
  console.log( "Injecting Stage CSS into Base Twig File" );
  var injectStage = gulp.src( './dist/css/styles.css', {read: false} );

  return injectTarget.pipe( $.inject( injectStage ) )
    .pipe( gulp.dest('./templates/partials' ) );
});

actually just got it working with a transform!

gulp.task('stage-inject', function() {
  console.log( "Injecting Stage CSS into Base Twig File" );
  var injectStage = gulp.src( './dist/css/styles.css', {read: true} );

  return injectTarget.pipe( $.inject( injectStage, {
    addRootSlash: false,
    transform: function (filepath) {
      console.log(filepath);
      return '{% do assets.addCss("theme://' + filepath + '") %}';
    }
  } ) )
    .pipe( gulp.dest('./templates/partials' ) );
});
rejas commented

So, this can be closed?

yes, sorry!