-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #169 from nextcloud-libraries/fix/minify
fix(base): Correctly pass minify configuration to vite
- Loading branch information
Showing
4 changed files
with
64 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/** | ||
* SPDX-FileCopyrightText: 2024 Ferdinand Thiessen <opensource@fthiessen.de> | ||
* | ||
* SPDX-License-Identifier: AGPL-3.0-or-later | ||
*/ | ||
|
||
import { describe, expect, it } from 'vitest' | ||
import { BaseOptions, createBaseConfig } from '../lib/baseConfig' | ||
import { resolveConfig } from 'vite' | ||
|
||
const createConfig = async ( | ||
command: 'build' | 'serve' = 'build', | ||
mode: 'development' | 'production' = 'production', | ||
options?: BaseOptions, | ||
) => | ||
await resolveConfig( | ||
await createBaseConfig( | ||
options, | ||
)({ command, mode, isSsrBuild: false }), | ||
command, | ||
) | ||
|
||
describe('baseconfig', () => { | ||
it('Correctly set minify option to false', async () => { | ||
const config = await createConfig('build', 'production', { minify: false }) | ||
expect(config.build.minify).toBe(false) | ||
expect(config.plugins.find(({ name }) => name === 'esbuild-minify')).toBeUndefined() | ||
}) | ||
|
||
it('Correctly set minify option to true', async () => { | ||
const config = await createConfig('build', 'production', { minify: true }) | ||
expect(config.build.minify).toBe('esbuild') | ||
expect(config.plugins.findIndex(({ name }) => name === 'esbuild-minify')).toBeGreaterThanOrEqual(0) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters