Created
April 2, 2020 17:50
-
-
Save Gennnji/1f452deb1d739c941eea96246beb0d8d to your computer and use it in GitHub Desktop.
Setup sirv-cli for Rollup with SSL and HTTP/2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# OpenSSL configuration to generate a new key with signing requst for a x509v3 | |
# multidomain certificate | |
# | |
# openssl req -config bla.cnf -new | tee csr.pem | |
# or | |
# openssl req -config bla.cnf -new -out csr.pem | |
[ req ] | |
default_bits = 4096 | |
default_md = sha512 | |
default_keyfile = key.pem | |
prompt = no | |
encrypt_key = no | |
# base request | |
distinguished_name = req_distinguished_name | |
# extensions | |
req_extensions = v3_req | |
# distinguished_name | |
[ req_distinguished_name ] | |
countryName = "DE" # C= | |
stateOrProvinceName = "Hessen" # ST= | |
localityName = "Keller" # L= | |
postalCode = "424242" # L/postalcode= | |
streetAddress = "Crater 1621" # L/street= | |
organizationName = "apfelboymschule" # O= | |
organizationalUnitName = "IT Department" # OU= | |
commonName = "example.com" # CN= | |
emailAddress = "[email protected]" # CN/emailAddress= | |
# req_extensions | |
[ v3_req ] | |
# The subject alternative name extension allows various literal values to be | |
# included in the configuration file | |
# http://www.openssl.org/docs/apps/x509v3_config.html | |
subjectAltName = DNS:www.example.com,DNS:www2.example.com # multidomain certificate | |
# vim:ft=config |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"scripts": { | |
"dev": "rollup -c -w", | |
"dev:serve": "sirv public --dev --port 5000 --http2 --key server.key --cert server.cert", | |
"setup:ssl": "openssl req -nodes -new -x509 -keyout server.key -out server.cert -config openssl.cnf", | |
"start": "run-s setup:ssl dev:serve" | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const production = !process.env.ROLLUP_WATCH; | |
export default { | |
input: 'main.js', | |
output: [ | |
{ | |
sourcemap: true, | |
format: 'iife', | |
name: 'App', | |
file: 'public/build/bundle.js' | |
}, | |
], | |
plugins: [ | |
svelte({ | |
hydratable: true, | |
dev: !production, | |
}), | |
resolve({ | |
browser: true, | |
dedupe: importee => importee === 'svelte' || importee.startsWith('svelte/') | |
}), | |
commonjs(), | |
!production && serve(), | |
production && terser(), | |
], | |
watch: { | |
clearScreen: false | |
}, | |
} | |
function serve() { | |
let started = false; | |
return { | |
writeBundle() { | |
if (!started) { | |
started = true; | |
require('child_process').spawn('npm', ['run', 'start'], { | |
stdio: ['ignore', 'inherit', 'inherit'], | |
shell: true | |
}); | |
} | |
} | |
}; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
yarn add --dev sirv-cli@next |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment