Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: optional files option #113

Merged
merged 1 commit into from
Jul 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ BundleMon config can be placed in other places like: `.bundlemonrc`, `.bundlemon
| Name | Description | Type | Default |
| ------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------- | --------------- |
| baseDir | Relative/absolute path to the directory | `string` | `process.cwd()` |
| files | [Files config](./docs/types.md#File) | `FileConfig[]` **required** | - |
| files | [Files config](./docs/types.md#File) | `FileConfig[]` | - |
| groups | Sum all file sizes matching the pattern, rules applies to the sum of the files [Groups config](./docs/types.md#File) | `FileConfig[]` | - |
| defaultCompression | Use compression before calculating file size | `"none"` \| `"gzip"` \| `"brotli"` | `"gzip"` |
| reportOutput | [Output options](./docs/output.md) | `(string \| [string, object])[]` | [] |
Expand Down
4 changes: 2 additions & 2 deletions packages/bundlemon/src/main/utils/configUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ function getConfigSchema() {
// @ts-expect-error
yup.lazy((val) => (typeof val === 'string' ? yup.string().required() : yup.array().required().min(2).max(2)))
),
files: yup.array().required().min(1).of(fileSchema),
files: yup.array().optional().of(fileSchema),
groups: yup.array().optional().of(fileSchema),
});

Expand All @@ -83,7 +83,7 @@ export function validateConfig(config: Config): NormalizedConfig | undefined {
const {
subProject,
baseDir = process.cwd(),
files,
files = [],
groups = [],
defaultCompression: defaultCompressionOption,
...restConfig
Expand Down