mirror of
https://github.com/kevin-DL/sapper.git
synced 2026-01-19 13:55:21 +00:00
add --host option to sapper export
This commit is contained in:
@@ -18,6 +18,7 @@ type Opts = {
|
|||||||
cwd?: string,
|
cwd?: string,
|
||||||
static?: string,
|
static?: string,
|
||||||
basepath?: string,
|
basepath?: string,
|
||||||
|
host_header?: string,
|
||||||
timeout?: number | false,
|
timeout?: number | false,
|
||||||
concurrent?: number,
|
concurrent?: number,
|
||||||
oninfo?: ({ message }: { message: string }) => void;
|
oninfo?: ({ message }: { message: string }) => void;
|
||||||
@@ -44,6 +45,7 @@ async function _export({
|
|||||||
build_dir = '__sapper__/build',
|
build_dir = '__sapper__/build',
|
||||||
export_dir = '__sapper__/export',
|
export_dir = '__sapper__/export',
|
||||||
basepath = '',
|
basepath = '',
|
||||||
|
host_header,
|
||||||
timeout = 5000,
|
timeout = 5000,
|
||||||
concurrent = 8,
|
concurrent = 8,
|
||||||
oninfo = noop,
|
oninfo = noop,
|
||||||
@@ -140,6 +142,7 @@ async function _export({
|
|||||||
|
|
||||||
const r = await Promise.race([
|
const r = await Promise.race([
|
||||||
fetch(url.href, {
|
fetch(url.href, {
|
||||||
|
headers: { host: host_header || host },
|
||||||
redirect: 'manual'
|
redirect: 'manual'
|
||||||
}),
|
}),
|
||||||
timeout_deferred.promise
|
timeout_deferred.promise
|
||||||
|
|||||||
@@ -194,6 +194,7 @@ prog.command('export [dest]')
|
|||||||
.describe('Export your app as static files (if possible)')
|
.describe('Export your app as static files (if possible)')
|
||||||
.option('--build', '(Re)build app before exporting', true)
|
.option('--build', '(Re)build app before exporting', true)
|
||||||
.option('--basepath', 'Specify a base path')
|
.option('--basepath', 'Specify a base path')
|
||||||
|
.option('--host', 'Host header to use when crawling site')
|
||||||
.option('--concurrent', 'Concurrent requests', 8)
|
.option('--concurrent', 'Concurrent requests', 8)
|
||||||
.option('--timeout', 'Milliseconds to wait for a page (--no-timeout to disable)', 5000)
|
.option('--timeout', 'Milliseconds to wait for a page (--no-timeout to disable)', 5000)
|
||||||
.option('--legacy', 'Create separate legacy build')
|
.option('--legacy', 'Create separate legacy build')
|
||||||
@@ -210,6 +211,7 @@ prog.command('export [dest]')
|
|||||||
legacy: boolean,
|
legacy: boolean,
|
||||||
bundler?: 'rollup' | 'webpack',
|
bundler?: 'rollup' | 'webpack',
|
||||||
basepath?: string,
|
basepath?: string,
|
||||||
|
host?: string,
|
||||||
concurrent: number,
|
concurrent: number,
|
||||||
timeout: number | false,
|
timeout: number | false,
|
||||||
cwd: string,
|
cwd: string,
|
||||||
@@ -236,6 +238,7 @@ prog.command('export [dest]')
|
|||||||
build_dir: opts['build-dir'],
|
build_dir: opts['build-dir'],
|
||||||
export_dir: dest,
|
export_dir: dest,
|
||||||
basepath: opts.basepath,
|
basepath: opts.basepath,
|
||||||
|
host_header: opts.host,
|
||||||
timeout: opts.timeout,
|
timeout: opts.timeout,
|
||||||
concurrent: opts.concurrent,
|
concurrent: opts.concurrent,
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user