Using Gulp useref concatenate in footer.php(templating)

166 Views Asked by At

I use Gulp as my taskrunner. In my gulpfile.js I use useref to concatenate my JS files. It works fine, when my scripts are in my index.php file. But if I try move them to ex footer.php for templating reasons, the useref won't concatenate the scripts to dist/master/footer.php

Gulp code:

gulp.task('useref', function() {
  return gulp.src('app/**/*.php')
    .pipe(useref())
    .pipe(gulpIf('*.js', uglify()))
    .pipe(gulpIf('*.css', cssnano()))
    .pipe(gulp.dest('dist'));
});

footer.php file:

    </main>
    <!-- page content end-->

    <!-- page footer -->
    <footer class="site-footer">
        test
    </footer>

    <!--build:js js/app.min.js -->
    <script src="js/jquery.js"></script>
    <script src="js/jquery-validate.js"></script>
    <script src="js/skip-link.js"></script> <!-- script for keyboards users to tap easy to content -->
    <script src="js/svg4all.js"></script>
    <script src="js/picturefill.js"></script>
    <script src="js/app.js"></script>
    <!-- endbuild -->
    </body>
</html>

I include the footer.php in my index.php file(at the end of the doc).

Is it possible to make gulp useref to concatenate JS files in a templating file as my footer.php?

0

There are 0 best solutions below