Add .gitignore file and retrieve proxy from ignored config.json

Created on 27 February 2019, about 6 years ago
Updated 15 April 2024, 12 months ago

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.

Feature request
Status

Needs work

Version

1.0

Component

Code

Created by

leymannx Berlin

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024