mirror of
https://github.com/kevin-DL/sapper.git
synced 2026-01-12 11:15:14 +00:00
29 lines
593 B
TypeScript
29 lines
593 B
TypeScript
import * as path from 'path';
|
|
import relative from 'require-relative';
|
|
|
|
export default function create_compilers() {
|
|
const webpack = relative('webpack', process.cwd());
|
|
|
|
return {
|
|
client: webpack(
|
|
require(path.resolve('webpack/client.config.js'))
|
|
),
|
|
|
|
server: webpack(
|
|
require(path.resolve('webpack/server.config.js'))
|
|
),
|
|
|
|
serviceWorker: webpack(
|
|
tryRequire(path.resolve('webpack/server.config.js'))
|
|
)
|
|
};
|
|
}
|
|
|
|
function tryRequire(specifier: string) {
|
|
try {
|
|
return require(specifier);
|
|
} catch (err) {
|
|
if (err.code === 'MODULE_NOT_FOUND') return null;
|
|
throw err;
|
|
}
|
|
} |