Answer the question
In order to leave comments, you need to log in
How to insert styles on a page launched with watcher and life reload?
Something like:
<script type="text/javascript">
// Кажется в gulpfile.js не будет виден document
...
const watch = require('gulp-watch');
const browserSync = require("browser-sync");
const reload = browserSync.reload;
gulp.prototype.appendToPage = function(CompiledStyle) {
if( this.isAppended() )return;
let styleTag = document.createElement('style');
styleTag.innerHTML = CompiledStyle;
document.getElementByID('HEAD').appendChild( styleTag );
};
gulp.task('build::style', function () {
return combiner(
gulp.src(path.src.style)
// ,sourcemaps.init()
// ,sass().on('error', sass.logError)
// ,prefixer()
// ,cssmin()
// ,sourcemaps.write()
//,gulp.dest(path.build.code)
,gulp.appendToPage(this) // <== append to page instead move to destination
,reload({stream: true})
);
});
...
</script>
<link
rel="stylesheet"
href="assets/css/modules/livereload.css"
>
Answer the question
In order to leave comments, you need to log in
What did you make up.
Yes, it is possible, but with a large number of files it loads the system, so if you are not good at incremental processing, I do not advise using liverelad. Fingers will not fall off, it will be updated once or twice-fiftieth.
I have similar implemented on gulp-connect and gulp-livereload
gulp.task('connect', function() {
connect.server({
livereload: true
});
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question