Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A way to use transform while spitting out correct script/link tags? #216

Open
george-norris-salesforce opened this issue Jan 23, 2017 · 2 comments

Comments

@george-norris-salesforce

Is there a way to use transform (to modify a path) while at the same time using injects detecting of file type and spitting out correct and/or <script>?

inject(
    gulp.src([
      `${config.jsDestfolder}/bundle.js`,
      `${config.cssDestfolder}/all.css`,
    ]),
    { transform: filePath => (
       //spits out correct path
       //but no html <link> or <script> tag
      `${process.env.HEROKU_PREFIX}${filePath}`
    )}
  )
@SamanthaAdrichem
Copy link

I would like to know this too. I want to add a query parameter with a unique checkout hash to prevent caching.

@SamanthaAdrichem
Copy link

SamanthaAdrichem commented Apr 6, 2017

Actually, google answered me : http://stackoverflow.com/questions/32077264/how-to-change-path-when-including-file-with-gulp-inject

       .pipe( $.inject(
        gulp.src( ['src/main/webapp/static/dist/**/*.js'], { read : false } ), {
            addRootSlash : false,
            //ignorePath : 'src/main/webapp',
            transform : function ( filePath, file, i, length ) {
                var newPath = filePath.replace( 'src/main/webapp/', '' );
                console.log('inject script = '+ newPath);
                return '<script src="${pageContext.request.contextPath}/' + newPath  + '"></script>';
            }
        } ))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants