replace magic env vars with documented CLI flags

This commit is contained in:
Rich Harris
2018-10-09 08:33:25 -04:00
parent 52f40f9e63
commit 6ae9a5e7c5
4 changed files with 95 additions and 39 deletions

View File

@@ -16,19 +16,19 @@ type Opts = {
routes?: string;
dest?: string;
output?: string;
static_files?: string;
static?: string;
legacy?: boolean;
bundler?: 'rollup' | 'webpack';
oncompile?: ({ type, result }: { type: string, result: CompileResult }) => void;
};
export async function build({
cwd = process.cwd(),
src = path.join(cwd, 'src'),
routes = path.join(cwd, 'src/routes'),
output = path.join(cwd, '__sapper__'),
static_files = path.join(cwd, 'static'),
dest = path.join(cwd, '__sapper__/build'),
cwd,
src = 'src',
routes = 'src/routes',
output = '__sapper__',
static: static_files = 'static',
dest = '__sapper__/build',
bundler,
legacy = false,
@@ -36,6 +36,14 @@ export async function build({
}: Opts = {}) {
bundler = validate_bundler(bundler);
cwd = path.resolve(cwd);
src = path.resolve(cwd, src);
dest = path.resolve(cwd, dest);
routes = path.resolve(cwd, routes);
output = path.resolve(cwd, output);
static_files = path.resolve(cwd, static_files);
dest = path.resolve(cwd, dest);
if (legacy && bundler === 'webpack') {
throw new Error(`Legacy builds are not supported for projects using webpack`);
}