Skip to content

Commit 2fc1ba0

Browse files
committed
feat: add gzip for dev build server
1 parent bfb953f commit 2fc1ba0

File tree

5 files changed

+264
-0
lines changed

5 files changed

+264
-0
lines changed

packages/vite/LICENSE.md

Lines changed: 216 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -554,6 +554,37 @@ Repositories: sindresorhus/bundle-name, sindresorhus/default-browser, sindresorh
554554
555555
---------------------------------------
556556

557+
## bytes
558+
License: MIT
559+
By: TJ Holowaychuk, Jed Watson, Théo FIDRY
560+
Repository: visionmedia/bytes.js
561+
562+
> (The MIT License)
563+
>
564+
> Copyright (c) 2012-2014 TJ Holowaychuk <[email protected]>
565+
> Copyright (c) 2015 Jed Watson <[email protected]>
566+
>
567+
> Permission is hereby granted, free of charge, to any person obtaining
568+
> a copy of this software and associated documentation files (the
569+
> 'Software'), to deal in the Software without restriction, including
570+
> without limitation the rights to use, copy, modify, merge, publish,
571+
> distribute, sublicense, and/or sell copies of the Software, and to
572+
> permit persons to whom the Software is furnished to do so, subject to
573+
> the following conditions:
574+
>
575+
> The above copyright notice and this permission notice shall be
576+
> included in all copies or substantial portions of the Software.
577+
>
578+
> THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
579+
> EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
580+
> MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
581+
> IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
582+
> CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
583+
> TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
584+
> SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
585+
586+
---------------------------------------
587+
557588
## cac
558589
License: MIT
559590
By: egoist
@@ -612,6 +643,69 @@ Repository: git+https://github.com/paulmillr/chokidar.git
612643
613644
---------------------------------------
614645

646+
## compressible
647+
License: MIT
648+
By: Douglas Christopher Wilson, Jonathan Ong, Jeremiah Senkpiel
649+
Repository: jshttp/compressible
650+
651+
> (The MIT License)
652+
>
653+
> Copyright (c) 2013 Jonathan Ong <[email protected]>
654+
> Copyright (c) 2014 Jeremiah Senkpiel <[email protected]>
655+
> Copyright (c) 2015 Douglas Christopher Wilson <[email protected]>
656+
>
657+
> Permission is hereby granted, free of charge, to any person obtaining
658+
> a copy of this software and associated documentation files (the
659+
> 'Software'), to deal in the Software without restriction, including
660+
> without limitation the rights to use, copy, modify, merge, publish,
661+
> distribute, sublicense, and/or sell copies of the Software, and to
662+
> permit persons to whom the Software is furnished to do so, subject to
663+
> the following conditions:
664+
>
665+
> The above copyright notice and this permission notice shall be
666+
> included in all copies or substantial portions of the Software.
667+
>
668+
> THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
669+
> EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
670+
> MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
671+
> IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
672+
> CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
673+
> TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
674+
> SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
675+
676+
---------------------------------------
677+
678+
## compression
679+
License: MIT
680+
By: Douglas Christopher Wilson, Jonathan Ong
681+
Repository: expressjs/compression
682+
683+
> (The MIT License)
684+
>
685+
> Copyright (c) 2014 Jonathan Ong <[email protected]>
686+
> Copyright (c) 2014-2015 Douglas Christopher Wilson <[email protected]>
687+
>
688+
> Permission is hereby granted, free of charge, to any person obtaining
689+
> a copy of this software and associated documentation files (the
690+
> 'Software'), to deal in the Software without restriction, including
691+
> without limitation the rights to use, copy, modify, merge, publish,
692+
> distribute, sublicense, and/or sell copies of the Software, and to
693+
> permit persons to whom the Software is furnished to do so, subject to
694+
> the following conditions:
695+
>
696+
> The above copyright notice and this permission notice shall be
697+
> included in all copies or substantial portions of the Software.
698+
>
699+
> THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
700+
> EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
701+
> MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
702+
> IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
703+
> CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
704+
> TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
705+
> SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
706+
707+
---------------------------------------
708+
615709
## connect
616710
License: MIT
617711
By: TJ Holowaychuk, Douglas Christopher Wilson, Jonathan Ong, Tim Caswell
@@ -1487,6 +1581,37 @@ Repository: https://github.com/rich-harris/magic-string
14871581
14881582
---------------------------------------
14891583

1584+
## mime-db
1585+
License: MIT
1586+
By: Douglas Christopher Wilson, Jonathan Ong, Robert Kieffer
1587+
Repository: jshttp/mime-db
1588+
1589+
> (The MIT License)
1590+
>
1591+
> Copyright (c) 2014 Jonathan Ong <[email protected]>
1592+
> Copyright (c) 2015-2022 Douglas Christopher Wilson <[email protected]>
1593+
>
1594+
> Permission is hereby granted, free of charge, to any person obtaining
1595+
> a copy of this software and associated documentation files (the
1596+
> 'Software'), to deal in the Software without restriction, including
1597+
> without limitation the rights to use, copy, modify, merge, publish,
1598+
> distribute, sublicense, and/or sell copies of the Software, and to
1599+
> permit persons to whom the Software is furnished to do so, subject to
1600+
> the following conditions:
1601+
>
1602+
> The above copyright notice and this permission notice shall be
1603+
> included in all copies or substantial portions of the Software.
1604+
>
1605+
> THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
1606+
> EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
1607+
> MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
1608+
> IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
1609+
> CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
1610+
> TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
1611+
> SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1612+
1613+
---------------------------------------
1614+
14901615
## mlly, ufo
14911616
License: MIT
14921617
Repositories: unjs/mlly, unjs/ufo
@@ -1572,6 +1697,38 @@ Repository: vercel/ms
15721697
15731698
---------------------------------------
15741699

1700+
## negotiator
1701+
License: MIT
1702+
By: Douglas Christopher Wilson, Federico Romero, Isaac Z. Schlueter
1703+
Repository: jshttp/negotiator
1704+
1705+
> (The MIT License)
1706+
>
1707+
> Copyright (c) 2012-2014 Federico Romero
1708+
> Copyright (c) 2012-2014 Isaac Z. Schlueter
1709+
> Copyright (c) 2014-2015 Douglas Christopher Wilson
1710+
>
1711+
> Permission is hereby granted, free of charge, to any person obtaining
1712+
> a copy of this software and associated documentation files (the
1713+
> 'Software'), to deal in the Software without restriction, including
1714+
> without limitation the rights to use, copy, modify, merge, publish,
1715+
> distribute, sublicense, and/or sell copies of the Software, and to
1716+
> permit persons to whom the Software is furnished to do so, subject to
1717+
> the following conditions:
1718+
>
1719+
> The above copyright notice and this permission notice shall be
1720+
> included in all copies or substantial portions of the Software.
1721+
>
1722+
> THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
1723+
> EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
1724+
> MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
1725+
> IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
1726+
> CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
1727+
> TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
1728+
> SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1729+
1730+
---------------------------------------
1731+
15751732
## normalize-path
15761733
License: MIT
15771734
By: Jon Schlinkert, Blaine Bublitz
@@ -1661,6 +1818,36 @@ Repository: jshttp/on-finished
16611818
16621819
---------------------------------------
16631820

1821+
## on-headers
1822+
License: MIT
1823+
By: Douglas Christopher Wilson
1824+
Repository: jshttp/on-headers
1825+
1826+
> (The MIT License)
1827+
>
1828+
> Copyright (c) 2014 Douglas Christopher Wilson
1829+
>
1830+
> Permission is hereby granted, free of charge, to any person obtaining
1831+
> a copy of this software and associated documentation files (the
1832+
> 'Software'), to deal in the Software without restriction, including
1833+
> without limitation the rights to use, copy, modify, merge, publish,
1834+
> distribute, sublicense, and/or sell copies of the Software, and to
1835+
> permit persons to whom the Software is furnished to do so, subject to
1836+
> the following conditions:
1837+
>
1838+
> The above copyright notice and this permission notice shall be
1839+
> included in all copies or substantial portions of the Software.
1840+
>
1841+
> THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
1842+
> EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
1843+
> MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
1844+
> IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
1845+
> CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
1846+
> TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
1847+
> SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1848+
1849+
---------------------------------------
1850+
16641851
## parse5
16651852
License: MIT
16661853
By: Ivan Nikulin, https://github.com/inikulin/parse5/graphs/contributors
@@ -2075,6 +2262,35 @@ Repositories: lukeed/resolve.exports, lukeed/totalist
20752262
20762263
---------------------------------------
20772264

2265+
## safe-buffer
2266+
License: MIT
2267+
By: Feross Aboukhadijeh
2268+
Repository: git://github.com/feross/safe-buffer.git
2269+
2270+
> The MIT License (MIT)
2271+
>
2272+
> Copyright (c) Feross Aboukhadijeh
2273+
>
2274+
> Permission is hereby granted, free of charge, to any person obtaining a copy
2275+
> of this software and associated documentation files (the "Software"), to deal
2276+
> in the Software without restriction, including without limitation the rights
2277+
> to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
2278+
> copies of the Software, and to permit persons to whom the Software is
2279+
> furnished to do so, subject to the following conditions:
2280+
>
2281+
> The above copyright notice and this permission notice shall be included in
2282+
> all copies or substantial portions of the Software.
2283+
>
2284+
> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
2285+
> IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
2286+
> FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
2287+
> AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
2288+
> LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2289+
> OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2290+
> THE SOFTWARE.
2291+
2292+
---------------------------------------
2293+
20782294
## shebang-command
20792295
License: MIT
20802296
By: Kevin Mårtensson

packages/vite/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@
9797
"fsevents": "~2.3.3"
9898
},
9999
"devDependencies": {
100+
"compression": "^1.8.0",
100101
"@ampproject/remapping": "^2.3.0",
101102
"@babel/parser": "^7.27.2",
102103
"@jridgewell/trace-mapping": "^0.3.25",

packages/vite/src/node/server/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import type { Connect } from 'dep-types/connect'
1515
import launchEditorMiddleware from 'launch-editor-middleware'
1616
import type { SourceMap } from 'rolldown'
1717
import type { ModuleRunner } from 'vite/module-runner'
18+
import compression from 'compression'
1819
import type { CommonServerOptions } from '../http'
1920
import {
2021
httpServerStart,
@@ -932,6 +933,8 @@ export async function _createServer(
932933
}
933934

934935
if (config.experimental.fullBundleMode) {
936+
// enable gzip for larger js file to make dev load file faster
937+
middlewares.use(compression({ enforceEncoding: 'gzip' }))
935938
// serve memory output dist files
936939
middlewares.use(memoryFilesMiddleware(server, false))
937940
} else {

packages/vite/src/types/shims.d.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@ declare module 'connect' {
33
export = connect
44
}
55

6+
declare module 'compression' {
7+
const compression: (option: any) => any
8+
export = compression
9+
}
10+
611
declare module 'cors' {
712
function cors(options: any): any
813
export = cors

pnpm-lock.yaml

Lines changed: 39 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)