There is a 1-pager website. It consists of index.php
that includes numerous sections (other PHP files). Each of the section includes links to JavaScript files.
Questions: is it possible to generate a single minified PHP file, that will have a single link to a single minified JS file (something similar to https://www.npmjs.com/package/gulp-sass
)?
I have managed to resolve this issue myself. It is possible to achieve the desired result with just 2 tools:
With concat I was able to concatenate all *.js files into logic.js
like this:
gulp.task('scripts', function () {
return gulp.src('src/**/*.js')
.pipe(concat('logic.js'))
.pipe(uglify())
.pipe(gulp.dest('dist/js'));
});
With ghfi I was able to include all included PHPs and then minify the result into a single index.php
:
gulp.task('php', function () {
gulp.src('src/index.php')
.pipe(gulpHandlebarsFileInclude())
.pipe(htmlmin({
collapseWhitespace: true
}))
.pipe(gulp.dest('dist'));
});
Had to include child-PHP files indside the parent one like this:
{{ fileInclude 'src/foo.php' }}
PS: the person who down-voted my question - you are truly amazing.