Skip to content

Instantly share code, notes, and snippets.

@jimmyadaro
Last active June 27, 2020 11:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jimmyadaro/c0be14a8484e6d42b73ef9d44deaaba7 to your computer and use it in GitHub Desktop.
Save jimmyadaro/c0be14a8484e6d42b73ef9d44deaaba7 to your computer and use it in GitHub Desktop.
Gulp with local HTTPS
// If you're using XAMPP on macOS, you can use "Secure-Vhost"
// @link: https://github.com/jimmyadaro/secure-vhost
var local_dev_url = "my-site.local",
path_to_local_dev_key = "/path/to/Secure-Vhost/"+local_dev_url+"/cert.key",
path_to_local_dev_cert = "/path/to/Secure-Vhost/"+local_dev_url+"/cert.crt";
// ...
browserSync.init({
open: 'external',
host: local_dev_url,
proxy: "https://"+local_dev_url,
port: 8888,
https: {
key: path_to_local_dev_key,
cert: path_to_local_dev_cert
},
// Add a nonce to the browserSync script tag
// You can add that nonce to your CSP (Content Security Policy)
// Example: "script-src 'self' 'nonce-browser-sync'"
snippetOptions: {
rule: {
match: /<\/head>/i,
fn: function (snippet, match) {
return snippet.replace('id=', `nonce="browser-sync" id=`) + match;
}
}
}
});
// ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment