mirror of
https://github.com/kevin-DL/sapper.git
synced 2026-01-12 11:15:14 +00:00
Merge pull request #632 from pngwn/master
Add support for custom route file extensions.
This commit is contained in:
@@ -19,6 +19,7 @@ type Opts = {
|
||||
static?: string;
|
||||
legacy?: boolean;
|
||||
bundler?: 'rollup' | 'webpack';
|
||||
ext?: string;
|
||||
oncompile?: ({ type, result }: { type: string, result: CompileResult }) => void;
|
||||
};
|
||||
|
||||
@@ -32,6 +33,7 @@ export async function build({
|
||||
|
||||
bundler,
|
||||
legacy = false,
|
||||
ext,
|
||||
oncompile = noop
|
||||
}: Opts = {}) {
|
||||
bundler = validate_bundler(bundler);
|
||||
@@ -68,7 +70,7 @@ export async function build({
|
||||
|
||||
fs.writeFileSync(`${dest}/template.html`, minify_html(template));
|
||||
|
||||
const manifest_data = create_manifest_data(routes);
|
||||
const manifest_data = create_manifest_data(routes, ext);
|
||||
|
||||
// create src/node_modules/@sapper/app.mjs and server.mjs
|
||||
create_app({
|
||||
|
||||
@@ -28,7 +28,8 @@ type Opts = {
|
||||
hot?: boolean,
|
||||
'devtools-port'?: number,
|
||||
bundler?: 'rollup' | 'webpack',
|
||||
port?: number
|
||||
port?: number,
|
||||
ext: string
|
||||
};
|
||||
|
||||
export function dev(opts: Opts) {
|
||||
@@ -47,7 +48,7 @@ class Watcher extends EventEmitter {
|
||||
}
|
||||
port: number;
|
||||
closed: boolean;
|
||||
|
||||
|
||||
dev_port: number;
|
||||
live: boolean;
|
||||
hot: boolean;
|
||||
@@ -67,6 +68,7 @@ class Watcher extends EventEmitter {
|
||||
unique_warnings: Set<string>;
|
||||
unique_errors: Set<string>;
|
||||
}
|
||||
ext: string;
|
||||
|
||||
constructor({
|
||||
cwd = '.',
|
||||
@@ -80,7 +82,8 @@ class Watcher extends EventEmitter {
|
||||
hot,
|
||||
'devtools-port': devtools_port,
|
||||
bundler,
|
||||
port = +process.env.PORT
|
||||
port = +process.env.PORT,
|
||||
ext
|
||||
}: Opts) {
|
||||
super();
|
||||
|
||||
@@ -95,7 +98,7 @@ class Watcher extends EventEmitter {
|
||||
output: path.resolve(cwd, output),
|
||||
static: path.resolve(cwd, static_files)
|
||||
};
|
||||
|
||||
this.ext = ext;
|
||||
this.port = port;
|
||||
this.closed = false;
|
||||
|
||||
@@ -161,7 +164,7 @@ class Watcher extends EventEmitter {
|
||||
let manifest_data: ManifestData;
|
||||
|
||||
try {
|
||||
manifest_data = create_manifest_data(routes);
|
||||
manifest_data = create_manifest_data(routes, this.ext);
|
||||
create_app({
|
||||
bundler: this.bundler,
|
||||
manifest_data,
|
||||
@@ -189,7 +192,7 @@ class Watcher extends EventEmitter {
|
||||
},
|
||||
() => {
|
||||
try {
|
||||
const new_manifest_data = create_manifest_data(routes);
|
||||
const new_manifest_data = create_manifest_data(routes, this.ext);
|
||||
create_app({
|
||||
bundler: this.bundler,
|
||||
manifest_data, // TODO is this right? not new_manifest_data?
|
||||
|
||||
Reference in New Issue
Block a user