0

During Gulp build .tmp process all js & css files are injected into temporary jsp file, but when dist process starts combined js & css files are generated but not injected into dist jsp file.

For same case build with html, file gulp working fine.

Is it possible to use gulp-inject for JSP files to inject javascript & css files into it? And how?

2
  • 1
    And your code / configuration files? Commented Aug 7, 2015 at 11:02
  • 1
    Please provide your code . Commented Aug 8, 2015 at 6:43

2 Answers 2

1

I managed to fix Gulp built process for .jsp files, implemented simple Gulp html build task, initial jsp view was called like Test.jsp.html, and then in last pipe, when all javascript and css was already injected into Test.jsp.html and then just rename it to Test.jsp.

Sign up to request clarification or add additional context in comments.

Comments

1

I guess you don't need any hack to solve this problem:

gulp.task('src-home-page', function(){

var resourcesToInject =  gulp.src(
    [sourcePaths.build + 'vendor/**/*.js'
        ,sourcePaths.build + 'home/**/*.js'],
    {read: false});

return gulp
    .src(youFilePath + '/file.jsp')
    .pipe($.inject(
      resourcesToInject,{
            transform: transoformResourceInclude
        }
      )
    )
    .pipe(gulp.dest('./src/main/webapp/WEB-INF/views/'));
});

function transoformResourceInclude(filePath){


var path = filePath.split('/').filter(function(slicePath){
    return slicePath != '' &&
        slicePath != 'src' && slicePath != 'main'
        && slicePath != 'webapp';
});

return  '<script src="<c:url value="/'+ path.join('/') +'" />"></script>';
}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.