From df2e22d03f2445cffd4063b4f8dcaaa78f81be74 Mon Sep 17 00:00:00 2001 From: jglee96 Date: Tue, 6 Jun 2023 04:39:15 +0900 Subject: [PATCH] fix: change emit compressed file and delete original assets order (#30) * fix: change emit compressed file and delete original assets order * fix: `closeBundle` file processing --------- Co-authored-by: kanno <812137533@qq.com> --- __tests__/plugin.spec.ts | 12 ++++++++++++ src/index.ts | 9 ++++++--- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/__tests__/plugin.spec.ts b/__tests__/plugin.spec.ts index 37fc69a..24a61ec 100644 --- a/__tests__/plugin.spec.ts +++ b/__tests__/plugin.spec.ts @@ -200,3 +200,15 @@ test('exclude-assets', async (t) => { const compressed = len(r.filter((s) => s.endsWith('.gz'))) t.is(compressed, 2) }) + +test('aws s3', async (t) => { + const id = await mockBuild({ filename: '[path][base]', deleteOriginalAssets: true }, 'dynamic') + await sleep(3000) + const r = await readAll(path.join(dist, id)) + const compressed = len(r.filter((s) => s.endsWith('.gz'))) + t.is(compressed, 0) + // eslint-disable-next-line padded-blocks + const css = r.filter(v => v.endsWith('.css'))[0] + const bf = zlib.unzipSync(fs.readFileSync(css)) + t.is(bf.toString(), '.pr{padding-right:30px}.pl{padding-left:30px}.mt{margin-top:30px}\n') +}) diff --git a/src/index.ts b/src/index.ts index 819b35d..07f29f9 100644 --- a/src/index.ts +++ b/src/index.ts @@ -156,9 +156,10 @@ function compression(opts: ViteCompressionPluginConfig(opts: ViteCompressionPluginConfig