update folder structure (#432)

This commit is contained in:
Rich Harris
2018-09-19 12:02:11 -04:00
parent f29e7efbd6
commit 8f064fe5ac
59 changed files with 680 additions and 27 deletions

View File

@@ -39,9 +39,9 @@ async function execute(emitter: EventEmitter, opts: Opts, dirs: Dirs) {
mkdirp.sync(`${dirs.dest}/client`);
copy_shimport(dirs.dest);
// minify app/template.html
// minify src/template.html
// TODO compile this to a function? could be quicker than str.replace(...).replace(...).replace(...)
const template = fs.readFileSync(`${dirs.app}/template.html`, 'utf-8');
const template = fs.readFileSync(`${dirs.src}/template.html`, 'utf-8');
// remove this in a future version
if (template.indexOf('%sapper.base%') === -1) {
@@ -54,7 +54,7 @@ async function execute(emitter: EventEmitter, opts: Opts, dirs: Dirs) {
const manifest_data = create_manifest_data();
// create app/manifest/client.js and app/manifest/server.js
// 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);
@@ -79,7 +79,7 @@ async function execute(emitter: EventEmitter, opts: Opts, dirs: Dirs) {
// TODO duration/warnings
result: client_result
});
client_result.to_json(manifest_data, dirs);
build_info.legacy_assets = client_result.assets;
delete process.env.SAPPER_LEGACY_BUILD;

View File

@@ -23,7 +23,7 @@ export function dev(opts) {
class Watcher extends EventEmitter {
bundler: string;
dirs: {
app: string;
src: string;
dest: string;
routes: string;
rollup: string;
@@ -53,7 +53,7 @@ class Watcher extends EventEmitter {
}
constructor({
app = locations.app(),
src = locations.src(),
dest = locations.dest(),
routes = locations.routes(),
'dev-port': dev_port,
@@ -65,7 +65,7 @@ class Watcher extends EventEmitter {
rollup = 'rollup',
port = +process.env.PORT
}: {
app: string,
src: string,
dest: string,
routes: string,
'dev-port': number,
@@ -80,7 +80,7 @@ class Watcher extends EventEmitter {
super();
this.bundler = validate_bundler(bundler);
this.dirs = { app, dest, routes, webpack, rollup };
this.dirs = { src, dest, routes, webpack, rollup };
this.port = port;
this.closed = false;
@@ -100,7 +100,7 @@ class Watcher extends EventEmitter {
};
// remove this in a future version
const template = fs.readFileSync(path.join(app, 'template.html'), 'utf-8');
const template = fs.readFileSync(path.join(src, 'template.html'), 'utf-8');
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`;
@@ -175,7 +175,7 @@ class Watcher extends EventEmitter {
}
),
fs.watch(`${locations.app()}/template.html`, () => {
fs.watch(`${locations.src()}/template.html`, () => {
this.dev_server.send({
action: 'reload'
});

View File

@@ -13,6 +13,7 @@ import * as events from './interfaces';
type Opts = {
build: string,
dest: string,
static: string,
basepath?: string,
timeout: number | false
};
@@ -46,7 +47,7 @@ async function execute(emitter: EventEmitter, opts: Opts) {
// Prep output directory
sander.rimrafSync(export_dir);
sander.copydirSync('assets').to(export_dir);
sander.copydirSync(opts.static).to(export_dir);
sander.copydirSync(opts.build, 'client').to(export_dir, 'client');
if (sander.existsSync(opts.build, 'service-worker.js')) {