@vercel/gatsby-plugin-vercel-builder
Advanced tools
Comparing version 1.0.3 to 1.1.0
@@ -14,3 +14,3 @@ "use strict"; | ||
loader: { '.ts': 'ts' }, | ||
outfile: path_1.join(outDir, './index.js'), | ||
outfile: path_1.join(outDir, 'index.js'), | ||
format: 'cjs', | ||
@@ -39,3 +39,4 @@ target: `node${major}`, | ||
}; | ||
return fs_extra_1.writeJson(`${functionDir}/.vc-config.json`, config); | ||
const configPath = path_1.join(functionDir, '.vc-config.json'); | ||
await fs_extra_1.writeJson(configPath, config); | ||
}; | ||
@@ -63,6 +64,2 @@ exports.writeVCConfig = writeVCConfig; | ||
}, | ||
// { | ||
// src: join(functionDir, '.cache', 'query-engine', 'assets'), | ||
// dest: join(functionDir, 'assets'), | ||
// }, | ||
{ | ||
@@ -69,0 +66,0 @@ src: path_1.join('.cache', 'data', 'datastore'), |
@@ -7,7 +7,14 @@ "use strict"; | ||
async function createStaticDir(prefix) { | ||
const publicDir = path_1.join(process.cwd(), 'public'); | ||
const targetDir = path_1.join(process.cwd(), '.vercel', 'output', 'static', prefix ?? ''); | ||
await fs_extra_1.ensureDir(targetDir); | ||
await fs_extra_1.copy(path_1.join(process.cwd(), 'public'), targetDir); | ||
await fs_extra_1.ensureDir(path_1.dirname(targetDir)); | ||
try { | ||
await fs_extra_1.move(publicDir, targetDir); | ||
} | ||
catch (err) { | ||
console.error(`Failed to move "public" dir from "${publicDir}" to "${targetDir}". Copying instead.`, err); | ||
await fs_extra_1.copy(publicDir, targetDir); | ||
} | ||
} | ||
exports.createStaticDir = createStaticDir; | ||
//# sourceMappingURL=static.js.map |
export interface GenerateVercelBuildOutputAPI3OutputOptions { | ||
exportPath: string; | ||
pathPrefix: string; | ||
gatsbyStoreState: { | ||
@@ -9,5 +9,4 @@ pages: Map<string, unknown>; | ||
}; | ||
[x: string]: unknown; | ||
} | ||
export declare function generateVercelBuildOutputAPI3Output({ exportPath, gatsbyStoreState, }: GenerateVercelBuildOutputAPI3OutputOptions): Promise<void>; | ||
export declare function generateVercelBuildOutputAPI3Output({ pathPrefix, gatsbyStoreState, }: GenerateVercelBuildOutputAPI3OutputOptions): Promise<void>; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -9,3 +9,3 @@ "use strict"; | ||
const static_1 = require("./helpers/static"); | ||
async function generateVercelBuildOutputAPI3Output({ exportPath, gatsbyStoreState, }) { | ||
async function generateVercelBuildOutputAPI3Output({ pathPrefix, gatsbyStoreState, }) { | ||
const state = { | ||
@@ -23,10 +23,12 @@ pages: Array.from(gatsbyStoreState.pages.entries()), | ||
.filter(page => page.mode === 'SSR' || page.mode === 'DSG'); | ||
const ops = [static_1.createStaticDir(gatsbyConfig.pathPrefix)]; | ||
const ops = []; | ||
if (functions.length > 0) { | ||
ops.push(functions_1.createAPIRoutes(functions, gatsbyConfig.pathPrefix)); | ||
ops.push(functions_1.createAPIRoutes(functions, pathPrefix)); | ||
} | ||
if (ssrRoutes.length > 0) { | ||
ops.push(functions_1.createServerlessFunctions(ssrRoutes, gatsbyConfig.pathPrefix)); | ||
ops.push(functions_1.createServerlessFunctions(ssrRoutes, pathPrefix)); | ||
} | ||
await Promise.all(ops); | ||
// "static" directory needs to happen last since it moves "public" | ||
await static_1.createStaticDir(pathPrefix); | ||
let trailingSlash = undefined; | ||
@@ -51,3 +53,3 @@ if (gatsbyConfig.trailingSlash === 'always') { | ||
}; | ||
await fs_extra_1.writeJson(exportPath, config); | ||
await fs_extra_1.writeJson('.vercel/output/config.json', config); | ||
console.log('Vercel output has been generated'); | ||
@@ -54,0 +56,0 @@ } |
@@ -12,5 +12,5 @@ import type { IGatsbyPage, IGatsbyFunction, IRedirect, IGatsbyConfig } from 'gatsby/dist/redux/types'; | ||
export declare type GatsbyRedirect = Pick<IRedirect, 'fromPath' | 'toPath' | 'isPermanent'>; | ||
export declare type GatsbyConfig = Pick<IGatsbyConfig, 'trailingSlash' | 'assetPrefix' | 'pathPrefix'>; | ||
export declare type GatsbyConfig = Pick<IGatsbyConfig, 'trailingSlash'>; | ||
export declare const ajv: Ajv; | ||
export declare const validateGatsbyState: import("ajv").ValidateFunction<GatsbyState>; | ||
//# sourceMappingURL=schemas.d.ts.map |
@@ -46,10 +46,2 @@ "use strict"; | ||
}, | ||
assetPrefix: { | ||
type: 'string', | ||
nullable: true, | ||
}, | ||
pathPrefix: { | ||
type: 'string', | ||
nullable: true, | ||
}, | ||
}, | ||
@@ -56,0 +48,0 @@ }; |
"use strict"; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.onPostBuild = exports.pluginOptionsSchema = void 0; | ||
const path_1 = __importDefault(require("path")); | ||
exports.onPostBuild = void 0; | ||
// this gets built separately, so import from "dist" instead of "src" | ||
const dist_1 = require("./dist"); | ||
const pluginOptionsSchema = ({ Joi, }) => { | ||
return Joi.object({ | ||
exportPath: Joi.string().optional(), | ||
}); | ||
}; | ||
exports.pluginOptionsSchema = pluginOptionsSchema; | ||
const onPostBuild = async ({ store }, pluginOptions) => { | ||
// validated by `pluginOptionSchema` | ||
const exportPath = (pluginOptions?.exportPath ?? | ||
path_1.default.join('.vercel', 'output', 'config.json')); | ||
const onPostBuild = async ({ pathPrefix, store, }) => { | ||
await dist_1.generateVercelBuildOutputAPI3Output({ | ||
exportPath, | ||
pathPrefix, | ||
// validated by `pluginOptionSchema` | ||
gatsbyStoreState: store.getState(), | ||
@@ -23,0 +11,0 @@ }); |
@@ -1,3 +0,1 @@ | ||
import path from 'path'; | ||
import type { GatsbyNode } from 'gatsby'; | ||
@@ -8,22 +6,11 @@ | ||
export const pluginOptionsSchema: GatsbyNode['pluginOptionsSchema'] = ({ | ||
Joi, | ||
export const onPostBuild: GatsbyNode['onPostBuild'] = async ({ | ||
pathPrefix, | ||
store, | ||
}) => { | ||
return Joi.object({ | ||
exportPath: Joi.string().optional(), | ||
}); | ||
}; | ||
export const onPostBuild: GatsbyNode['onPostBuild'] = async ( | ||
{ store }, | ||
pluginOptions | ||
) => { | ||
// validated by `pluginOptionSchema` | ||
const exportPath = (pluginOptions?.exportPath ?? | ||
path.join('.vercel', 'output', 'config.json')) as string; | ||
await generateVercelBuildOutputAPI3Output({ | ||
exportPath, | ||
pathPrefix, | ||
// validated by `pluginOptionSchema` | ||
gatsbyStoreState: store.getState(), | ||
}); | ||
}; |
{ | ||
"name": "@vercel/gatsby-plugin-vercel-builder", | ||
"version": "1.0.3", | ||
"version": "1.1.0", | ||
"main": "dist/index.js", | ||
@@ -17,4 +17,4 @@ "files": [ | ||
"dependencies": { | ||
"@vercel/build-utils": "6.0.1", | ||
"@vercel/node": "2.8.17", | ||
"@vercel/build-utils": "6.1.0", | ||
"@vercel/node": "2.9.0", | ||
"@vercel/routing-utils": "2.1.8", | ||
@@ -34,3 +34,3 @@ "ajv": "8.12.0", | ||
}, | ||
"gitHead": "ada9a48d57be8f4375494a369aaa98cee1f5eae2" | ||
"gitHead": "a4d16c681a7e85f64a2d78432d499c599b398bde" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
49647
37
517
+ Added@vercel/build-utils@6.1.0(transitive)
+ Added@vercel/node@2.9.0(transitive)
+ Added@vercel/static-config@2.0.12(transitive)
- Removed@vercel/build-utils@6.0.1(transitive)
- Removed@vercel/node@2.8.17(transitive)
- Removed@vercel/static-config@2.0.11(transitive)
Updated@vercel/build-utils@6.1.0
Updated@vercel/node@2.9.0