Skip to content

Commit

Permalink
Hackily put output under build.outDir (see solidjs#1063)
Browse files Browse the repository at this point in the history
  • Loading branch information
iainmerrick committed Oct 6, 2023
1 parent 23978e8 commit 7ee5179
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions packages/start-cloudflare-pages/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,22 +127,23 @@ export default function (miniflareOptions) {
},
async build(config, builder) {
const __dirname = dirname(fileURLToPath(import.meta.url));
const outDir = join(config.root, config.build.outDir);
if (!config.solidOptions.ssr) {
await builder.spaClient(join(config.root, "dist", "public"));
await builder.server(join(config.root, ".solid", "server"));
await builder.spaClient(join(outDir, "dist", "public"));
await builder.server(join(outDir, ".solid", "server"));
} else if (config.solidOptions.experimental.islands) {
await builder.islandsClient(join(config.root, "dist", "public"));
await builder.server(join(config.root, ".solid", "server"));
await builder.islandsClient(join(outDir, "dist", "public"));
await builder.server(join(outDir, ".solid", "server"));
} else {
await builder.client(join(config.root, "dist", "public"));
await builder.server(join(config.root, ".solid", "server"));
await builder.client(join(outDir, "dist", "public"));
await builder.server(join(outDir, ".solid", "server"));
}

writeFileSync(join(config.root, "dist", "public", "_headers"), getHeadersFile(), "utf8");
writeFileSync(join(outDir, "dist", "public", "_headers"), getHeadersFile(), "utf8");

copyFileSync(join(__dirname, "entry.js"), join(config.root, ".solid", "server", "server.js"));
copyFileSync(join(__dirname, "entry.js"), join(outDir, ".solid", "server", "server.js"));
const bundle = await rollup({
input: join(config.root, ".solid", "server", "server.js"),
input: join(outDir, ".solid", "server", "server.js"),
plugins: [
json(),
nodeResolve({
Expand All @@ -157,7 +158,7 @@ export default function (miniflareOptions) {
await bundle.write({
format: "esm",
inlineDynamicImports: true,
file: join(config.root, "functions", "[[path]].js")
file: join(outDir, "functions", "[[path]].js")
});

// closes the bundle
Expand Down

0 comments on commit 7ee5179

Please sign in to comment.