@serwist/webpack-plugin
Version:
A plugin for your webpack build process, helping you generate a manifest of local files that should be precached.
31 lines (25 loc) • 977 B
text/typescript
import { fn, basePartial, injectPartial as baseInjectPartial, optionalSwDestPartial } from "@serwist/build/schema";
import { z } from "zod";
const webpackConditionCallback = fn({
input: [z.any()],
output: z.boolean(),
});
const webpackCondition = z.union([z.string(), z.instanceof(RegExp), webpackConditionCallback]);
export const webpackPartial = z.strictObject({
chunks: z.array(z.string()).optional(),
exclude: z.array(webpackCondition).default([/\.map$/, /^manifest.*\.js$/]),
excludeChunks: z.array(z.string()).optional(),
include: z.array(webpackCondition).optional(),
});
export const injectPartial = z.strictObject({
compileSrc: z.boolean().default(true),
swDest: z.string().optional(),
webpackCompilationPlugins: z.array(z.any()).optional(),
});
export const injectManifestOptions = z.strictObject({
...basePartial.shape,
...webpackPartial.shape,
...baseInjectPartial.shape,
...optionalSwDestPartial.shape,
...injectPartial.shape,
});