mirror of
https://github.com/kevin-DL/sapper.git
synced 2026-01-13 11:35:28 +00:00
move config into single file, add errors to help people migrate
This commit is contained in:
@@ -11,6 +11,7 @@ import * as events from './interfaces';
|
||||
import { copy_shimport } from './utils/copy_shimport';
|
||||
import { Dirs, PageComponent } from '../interfaces';
|
||||
import { CompileResult } from '../core/create_compilers/interfaces';
|
||||
import read_template from '../core/read_template';
|
||||
|
||||
type Opts = {
|
||||
legacy: boolean;
|
||||
@@ -41,7 +42,7 @@ async function execute(emitter: EventEmitter, opts: Opts, dirs: Dirs) {
|
||||
|
||||
// minify src/template.html
|
||||
// TODO compile this to a function? could be quicker than str.replace(...).replace(...).replace(...)
|
||||
const template = fs.readFileSync(`${dirs.src}/template.html`, 'utf-8');
|
||||
const template = read_template();
|
||||
|
||||
// remove this in a future version
|
||||
if (template.indexOf('%sapper.base%') === -1) {
|
||||
@@ -57,7 +58,7 @@ async function execute(emitter: EventEmitter, opts: Opts, dirs: Dirs) {
|
||||
// create src/manifest/client.js and src/manifest/server.js
|
||||
create_main_manifests({ bundler: opts.bundler, manifest_data });
|
||||
|
||||
const { client, server, serviceworker } = create_compilers(opts.bundler, dirs);
|
||||
const { client, server, serviceworker } = await create_compilers(opts.bundler, dirs);
|
||||
|
||||
const client_result = await client.compile();
|
||||
emitter.emit('build', <events.BuildEvent>{
|
||||
@@ -70,7 +71,7 @@ async function execute(emitter: EventEmitter, opts: Opts, dirs: Dirs) {
|
||||
|
||||
if (opts.legacy) {
|
||||
process.env.SAPPER_LEGACY_BUILD = 'true';
|
||||
const { client } = create_compilers(opts.bundler, dirs);
|
||||
const { client } = await create_compilers(opts.bundler, dirs);
|
||||
|
||||
const client_result = await client.compile();
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@ import * as events from './interfaces';
|
||||
import validate_bundler from '../cli/utils/validate_bundler';
|
||||
import { copy_shimport } from './utils/copy_shimport';
|
||||
import { ManifestData } from '../interfaces';
|
||||
import read_template from '../core/read_template';
|
||||
|
||||
export function dev(opts) {
|
||||
return new Watcher(opts);
|
||||
@@ -100,7 +101,7 @@ class Watcher extends EventEmitter {
|
||||
};
|
||||
|
||||
// remove this in a future version
|
||||
const template = fs.readFileSync(path.join(src, 'template.html'), 'utf-8');
|
||||
const template = read_template();
|
||||
if (template.indexOf('%sapper.base%') === -1) {
|
||||
const error = new Error(`As of Sapper v0.10, your template.html file must include %sapper.base% in the <head>`);
|
||||
error.code = `missing-sapper-base`;
|
||||
@@ -185,7 +186,7 @@ class Watcher extends EventEmitter {
|
||||
let deferred = new Deferred();
|
||||
|
||||
// TODO watch the configs themselves?
|
||||
const compilers: Compilers = create_compilers(this.bundler, this.dirs);
|
||||
const compilers: Compilers = await create_compilers(this.bundler, this.dirs);
|
||||
|
||||
let log = '';
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import * as child_process from 'child_process';
|
||||
import { CompileResult } from '../core/create_compilers';
|
||||
import { CompileResult } from '../core/create_compilers/interfaces';
|
||||
|
||||
export type ReadyEvent = {
|
||||
port: number;
|
||||
|
||||
Reference in New Issue
Block a user