Skip to content

Commit 9359903

Browse files
committed
fix(vite): prune source by default
1 parent 9ba134e commit 9359903

File tree

3 files changed

+8
-12
lines changed

3 files changed

+8
-12
lines changed

packages/vite-plugin-beasties/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
},
3232
"scripts": {
3333
"build": "unbuild",
34+
"build:stub": "unbuild --stub",
3435
"dev": "vitest dev",
3536
"lint": "eslint . --fix",
3637
"prepare": "simple-git-hooks",

packages/vite-plugin-beasties/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ export function beasties(options: ViteBeastiesOptions = {}): Plugin {
2828
configResolved(resolvedConfig) {
2929
config = resolvedConfig
3030
beastiesInstance = new Beasties({
31+
pruneSource: true,
3132
...options.options,
3233
path: config.build.outDir,
3334
publicPath: config.base,

packages/vite-plugin-beasties/test/index.test.ts

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,7 @@ describe('vite-plugin-beasties', () => {
2424
write: false,
2525
},
2626
plugins: [
27-
beasties({
28-
options: {
29-
inlineThreshold: 5000,
30-
...options.options,
31-
},
32-
...options,
33-
}),
27+
beasties(options),
3428
],
3529
}) as RollupOutput
3630

@@ -56,16 +50,16 @@ describe('vite-plugin-beasties', () => {
5650
const hasCssColor = html?.includes('color: blue') || html?.includes('color:#00f')
5751
expect(hasCssColor).toBe(true)
5852

53+
// prunes source
5954
const css = output.find(file => file.fileName.endsWith('.css')) as any
60-
61-
expect(css.source.trim()).toMatchInlineSnapshot(`".test-content{color:#00f;font-weight:700}"`)
55+
expect(css.source.trim()).toMatchInlineSnapshot(`""`)
6256
})
6357

64-
it('prunes CSS files during the build', async () => {
65-
const { output } = await runViteBuild({ options: { pruneSource: true } })
58+
it('allows disabling pruning of source CSS files during the build', async () => {
59+
const { output } = await runViteBuild({ options: { pruneSource: false } })
6660
const css = output.find(file => file.fileName.endsWith('.css')) as any
6761

68-
expect(css.source.trim()).toMatchInlineSnapshot(`""`)
62+
expect(css.source.trim()).toMatchInlineSnapshot(`".test-content{color:#00f;font-weight:700}"`)
6963
})
7064

7165
it('respects the filter option', async () => {

0 commit comments

Comments
 (0)