-
Notifications
You must be signed in to change notification settings - Fork 273
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Compress CSS resources to keep the virtual size down (#621)
- Loading branch information
1 parent
51574f9
commit bec1cd8
Showing
8 changed files
with
48 additions
and
17 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,6 @@ | ||
--- | ||
'@vanilla-extract/integration': patch | ||
'@vanilla-extract/webpack-plugin': patch | ||
--- | ||
|
||
Improve build performance when creating large CSS files |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,18 @@ | ||
import zlib from 'zlib'; | ||
|
||
export function getSourceFromVirtualCssFile(id: string) { | ||
const match = id.match(/^(?<fileName>.*)\?source=(?<source>.*)$/) ?? []; | ||
|
||
if (!match || !match.groups) { | ||
throw new Error('No source in vanilla CSS file'); | ||
} | ||
|
||
const decompressedSource = zlib.gunzipSync( | ||
Buffer.from(match.groups.source, 'base64'), | ||
); | ||
|
||
return { | ||
fileName: match.groups.fileName, | ||
source: Buffer.from(match.groups.source, 'base64').toString('utf-8'), | ||
source: decompressedSource.toString('utf-8'), | ||
}; | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// @ts-expect-error | ||
import { getOptions } from 'loader-utils'; | ||
import zlib from 'zlib'; | ||
|
||
export default function (this: any) { | ||
const { source } = getOptions(this); | ||
|
||
const decompressedSource = zlib.gunzipSync(Buffer.from(source, 'base64')); | ||
|
||
return decompressedSource.toString('utf-8'); | ||
} |
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,4 @@ | ||
{ | ||
"main": "dist/vanilla-extract-webpack-plugin-virtual.cjs.js", | ||
"module": "dist/vanilla-extract-webpack-plugin-virtual.esm.js" | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.