This commit is contained in:
Richard Harris
2019-02-03 00:14:53 -05:00
parent 66be631572
commit 3d7cfbbf3d
26 changed files with 131 additions and 135 deletions

View File

@@ -9,6 +9,7 @@ import read_template from '../core/read_template';
import { CompileResult } from '../core/create_compilers/interfaces';
import { noop } from './utils/noop';
import validate_bundler from './utils/validate_bundler';
import { copy_runtime } from './utils/copy_runtime';
type Opts = {
cwd?: string;
@@ -49,6 +50,7 @@ export async function build({
rimraf.sync(path.join(output, '**/*'));
mkdirp.sync(output);
copy_runtime(output);
rimraf.sync(path.join(dest, '**/*'));
mkdirp.sync(`${dest}/client`);

View File

@@ -15,6 +15,7 @@ import { copy_shimport } from './utils/copy_shimport';
import { ManifestData, FatalEvent, ErrorEvent, ReadyEvent, InvalidEvent } from '../interfaces';
import read_template from '../core/read_template';
import { noop } from './utils/noop';
import { copy_runtime } from './utils/copy_runtime';
type Opts = {
cwd?: string,
@@ -147,6 +148,7 @@ class Watcher extends EventEmitter {
rimraf.sync(path.join(output, '**/*'));
mkdirp.sync(output);
copy_runtime(output);
rimraf.sync(dest);
mkdirp.sync(`${dest}/client`);

View File

@@ -0,0 +1,21 @@
import * as fs from 'fs';
import * as path from 'path';
import mkdirp from 'mkdirp';
const runtime = [
'app.mjs',
'server.mjs',
'internal/shared.mjs',
'internal/Sapper.html',
'internal/layout.html'
].map(file => ({
file,
source: fs.readFileSync(path.join(__dirname, `../runtime/${file}`), 'utf-8')
}));
export function copy_runtime(output: string) {
runtime.forEach(({ file, source }) => {
mkdirp.sync(path.dirname(`${output}/${file}`));
fs.writeFileSync(`${output}/${file}`, source);
});
}