Answer the question
In order to leave comments, you need to log in
Is it possible to make GULP run index.php?
I need to change Gulp's tracking to follow .php instead of HTML files.
const scss = require('gulp-sass')(require('sass'));
const { src, dest, watch, parallel } = require('gulp');
var concat = require('gulp-concat');
const autoprefixer = require('gulp-autoprefixer');
const uglify = require('gulp-uglify');
const browserSync = require('browser-sync').create();
function browsersync(){
browserSync.init({
server: {
baseDir: "app"
}
});
}
function styles() {
return src('app/scss/style.scss')
.pipe(scss({outputStyle: 'expanded'}))
.pipe(concat('style.css'))
.pipe(autoprefixer({
overrideBrowserslist: ['last 10 versions'],
grid: true
}))
.pipe(dest('app/css'))
.pipe(browserSync.stream())
}
function scripts() {
return src([
'app/js/main.js'
])
.pipe(concat('main.min.js'))
.pipe(uglify())
.pipe(dest('app/js'))
.pipe(browserSync.stream())
}
function watching() {
watch(['app/scss/**/*.scss'], styles);
watch(['app/js/**/*.js', '!app/js/main.min.js'], scripts);
watch(['app/**/*.html']).on('change', browserSync.reload);
}
exports.styles = styles;
exports.scripts = scripts;
exports.browsersync = browsersync;
exports.watching = watching;
exports.default = parallel(styles, scripts, browsersync, watching);
Answer the question
In order to leave comments, you need to log in
gulp tracks changes by date or file size, alas, a php script can contain include and return different results, while the date of modification and file size will remain unchanged. and what's the point in all of that? you can add gulp call in php generated html or call console command in php code
gulp reload php -> https://stackoverflow.com/questions/23448256/gulp-...
if you don't like it, you can add browsersync reload php
but that's all if the files are located locally, if on the server, then nothing....
Well, add it, business something ...
function watching() {
watch(['app/scss/**/*.scss'], styles);
watch(['app/js/**/*.js', '!app/js/main.min.js'], scripts);
// watch(['app/**/*.html']).on('change', browserSync.reload);
watch(['app/**/*.php']).on('change', browserSync.reload);
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question