Answer the question
In order to leave comments, you need to log in
How to change files from the deployment server to local ones using browserSync proxy?
Hello!
There is a deploy server on which the application is running.
I need that when opening localhost:3000 browserSync replaces certain files from the server deployment with local files.
For example:
the page requests
src="/public/dist/js/database_import_edit.bundle.js",
browserSync needs to take this path and replace it with the path to the local file.
Task for browserSync
gulp.task("watch", function () {
browserSync.init({
proxy: "http://example.lan",
files: ["./public/dist/js/**"],
serveStatic: ["./public/dist/js/"],
rewriteRules: [
{
match: new RegExp("dist/js/database_import_edit.bundle.js"),
fn: function() {
return "browsersync/database_import_edit.bundle.js"
}
}
]
});
gulp.watch(webcontrol_dir + "js/**/*.js", gulp.series("build:js"));
});
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question