parent
5e089ba27d
commit
3462113c2f
|
@ -83,8 +83,10 @@ You can export Pinafore as a static site. Run:
|
|||
npm run export
|
||||
|
||||
Static files will be written to `__sapper__/export`.
|
||||
Be sure to add the [CSP](https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP) header printed out in the console to
|
||||
your server config!
|
||||
|
||||
Note that this is not the recommended method, because
|
||||
[CSP](https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP) headers are not
|
||||
currently supported for the exported version.
|
||||
|
||||
## Developing and testing
|
||||
|
||||
|
|
|
@ -1,15 +1,3 @@
|
|||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
|
||||
const checksum = require('../inline-script-checksum').checksum
|
||||
const html = fs.readFileSync(path.join(__dirname, '../__sapper__/export/index.html'), 'utf8')
|
||||
const nonce = html.match(/<script nonce=([^>]+)>/)[1]
|
||||
|
||||
const csp = `add_header Content-Security-Policy "script-src 'self' 'sha256-${checksum}' 'nonce-${nonce}'; ` +
|
||||
`worker-src 'self'; style-src 'self' 'unsafe-inline'; frame-src 'none'; object-src 'none'; manifest-src 'self';`
|
||||
|
||||
fs.writeFileSync(path.join(__dirname, '../__sapper__/export/.csp.nginx'), csp, 'utf8')
|
||||
|
||||
console.log(`
|
||||
|
||||
,((*
|
||||
|
@ -36,13 +24,5 @@ Export successful! Static files are in:
|
|||
|
||||
__sapper__/export/
|
||||
|
||||
Be sure to add the CSP header to your nginx config:
|
||||
|
||||
server {
|
||||
include ${path.resolve(__dirname, '..')}/__sapper__/export/.csp.nginx;
|
||||
}
|
||||
|
||||
This file will be updated whenever you do \`npm run export\`.
|
||||
|
||||
Enjoy Pinafore!
|
||||
`)
|
||||
|
|
Loading…
Reference in a new issue