Imagine a dev studio with multiple developers working on the same site. Everybody has setup their local dev environment using a different local domain (example.test, example.local, example.localhost etc.). Instead of having the proxy hard coded into gulpfile.js
let's retrieve it from a gitignored config.json
file. An example.config.json
should be added and be taken as fallback.
example.config.json
:
{
"proxy": "http://yourdomain.com"
}
I'm no JS dev, so not sure about the use of var
in gulpfile.js
:
// Only include config if exists.
var config;
try {
config = require('./config.json');
} catch (error) {
config = require('./example.config.json');
}
And then when BrowserSync get initiated it would look like so:
// Static Server + watching scss/html files
function serve () {
browserSync.init({
proxy: config.proxy,
})
gulp.watch([paths.scss.watch, paths.scss.bootstrap], styles).on('change', browserSync.reload)
}
Apart from that I also inserted /node_modules/
in the .gitgnore
file, as this has hit me when I wanted to commit my sub-theme.