mirror of
https://github.com/kevin-DL/sapper.git
synced 2026-01-13 11:35:28 +00:00
tidy up a bit
This commit is contained in:
@@ -1,20 +1,11 @@
|
||||
import * as path from 'path';
|
||||
import mkdirp from 'mkdirp';
|
||||
import rimraf from 'rimraf';
|
||||
|
||||
export const dev = process.env.NODE_ENV !== 'production';
|
||||
|
||||
export const templates = path.resolve(process.env.SAPPER_TEMPLATES || 'templates');
|
||||
|
||||
export const src = path.resolve(process.env.SAPPER_ROUTES || 'routes');
|
||||
|
||||
export const dest = path.resolve(process.env.SAPPER_DEST || '.sapper');
|
||||
|
||||
if (dev) {
|
||||
mkdirp.sync(dest);
|
||||
rimraf.sync(path.join(dest, '**/*'));
|
||||
}
|
||||
|
||||
export const entry = {
|
||||
client: path.resolve(templates, '.main.rendered.js'),
|
||||
server: path.resolve(dest, 'server-entry.js')
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import * as fs from 'fs';
|
||||
import * as path from 'path';
|
||||
import glob from 'glob';
|
||||
import * as templates from './templates.js';
|
||||
import { create_templates, render } from './templates.js';
|
||||
import * as route_manager from './route_manager.js';
|
||||
|
||||
function ensure_array(thing) {
|
||||
@@ -9,7 +9,7 @@ function ensure_array(thing) {
|
||||
}
|
||||
|
||||
export default function generate_asset_cache({ src, dest, dev, client_info, server_info }) {
|
||||
templates.create_templates(); // TODO refactor this...
|
||||
create_templates(); // TODO refactor this...
|
||||
|
||||
const main_file = `/client/${ensure_array(client_info.assetsByChunkName.main)[0]}`;
|
||||
|
||||
@@ -71,7 +71,7 @@ function generate_service_worker({ chunk_files, src }) {
|
||||
}
|
||||
|
||||
function generate_index(main_file) {
|
||||
return templates.render(200, {
|
||||
return render(200, {
|
||||
styles: '',
|
||||
head: '',
|
||||
html: '<noscript>Please enable JavaScript!</noscript>',
|
||||
|
||||
@@ -1,12 +1,9 @@
|
||||
import * as path from 'path';
|
||||
import relative from 'require-relative';
|
||||
|
||||
const webpack = relative('webpack', process.cwd());
|
||||
|
||||
export let client;
|
||||
export let server;
|
||||
|
||||
export function get_compilers() {
|
||||
const webpack = relative('webpack', process.cwd());
|
||||
|
||||
return {
|
||||
client: webpack(
|
||||
require(path.resolve('webpack.client.config.js'))
|
||||
@@ -16,12 +13,4 @@ export function get_compilers() {
|
||||
require(path.resolve('webpack.server.config.js'))
|
||||
)
|
||||
};
|
||||
}
|
||||
|
||||
// export const client = webpack(
|
||||
// require(path.resolve('webpack.client.config.js'))
|
||||
// );
|
||||
|
||||
// export const server = webpack(
|
||||
// require(path.resolve('webpack.server.config.js'))
|
||||
// );
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
import * as fs from 'fs';
|
||||
import * as path from 'path';
|
||||
import * as route_manager from '../route_manager.js';
|
||||
import * as templates from '../templates.js';
|
||||
import { create_templates } from '../templates.js';
|
||||
|
||||
function posixify(file) {
|
||||
return file.replace(/[/\\]/g, '/');
|
||||
@@ -90,7 +90,7 @@ export function start_watching({ src }) {
|
||||
});
|
||||
|
||||
watch('templates/**.html', () => {
|
||||
templates.create_templates();
|
||||
create_templates();
|
||||
// TODO reload current page?
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
import * as fs from 'fs';
|
||||
import * as path from 'path';
|
||||
import mkdirp from 'mkdirp';
|
||||
import rimraf from 'rimraf';
|
||||
import serialize from 'serialize-javascript';
|
||||
import escape_html from 'escape-html';
|
||||
import { route_manager, templates, create_app, compilers, generate_asset_cache } from 'sapper/core.js';
|
||||
@@ -7,6 +9,9 @@ import create_watcher from './create_watcher.js';
|
||||
import { dest, dev, entry, src } from '../config.js';
|
||||
|
||||
function connect_dev() {
|
||||
mkdirp.sync(dest);
|
||||
rimraf.sync(path.join(dest, '**/*'));
|
||||
|
||||
create_app({ dev, entry, src });
|
||||
|
||||
const watcher = create_watcher();
|
||||
|
||||
Reference in New Issue
Block a user