Skip to content

Commit

Permalink
fix: fix lancher.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
dongwa committed May 19, 2022
1 parent 9bfa7c1 commit 95df856
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 3 deletions.
4 changes: 4 additions & 0 deletions src/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ export async function build(opts: BuildOptions): Promise<BuilderOutput> {
// }
// }
// Read nuxt.config.js
const quasarConfigName = 'quasar.config.js';
const quasarConfigFile = getQuasarConfig(entrypointPath);
// Read options from nuxt.config.js otherwise set sensible defaults
// const staticDir =
Expand Down Expand Up @@ -223,6 +224,9 @@ export async function build(opts: BuildOptions): Promise<BuilderOutput> {
'vercel__bridge.js': new FileFsRef({
fsPath: require('@vercel/node-bridge'),
}),
[quasarConfigName]: new FileFsRef({
fsPath: path.resolve(entrypointPath, quasarConfigName),
}),
// ...serverDistFiles,
...distFils,
...nodeModules,
Expand Down
36 changes: 33 additions & 3 deletions src/launcher.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,45 @@
import path from 'path';
import { getQuasarConfig } from './utils';

// Create bridge and start listening
const { Server } = require('http') as typeof import('http'); // eslint-disable-line import/order
const { Bridge } =
require('./vercel__bridge.js') as typeof import('@vercel/node-bridge/bridge');
let listener: any;

let quasarConfig;
const loaders = [
{ name: 'jiti', args: [] },
{
name: 'esm',
args: [
module,
{
cjs: {
dedefault: true,
},
},
],
},
];
for (const { name, args } of loaders) {
try {
const load = require(name)(...args);
const config = load('./quasar.config.js')({
dev: false,
prod: true,
});
quasarConfig = config.default || config;
break;
} catch (err) {
if (name === 'esm') {
throw new Error(
`Could not load Quasar configuration. Make sure all dependencies are listed in package.json dependencies or in serverFiles within builder options:\n ${err}`
);
}
}
}
console.log('quasar.congfig.js:', quasarConfig);
try {
process.chdir(__dirname);
const quasarConfig = getQuasarConfig(__dirname);

if (!process.env.PROT) process.env.PROT = quasarConfig.ssr.prodProd as any;
if (!process.env.NODE_ENV) process.env.NODE_ENV = 'production';
Expand Down

0 comments on commit 95df856

Please sign in to comment.