Skip to content

Commit

Permalink
Add compressible check
Browse files Browse the repository at this point in the history
  • Loading branch information
stramel committed Jun 3, 2020
1 parent a2e4eb5 commit 6600cf3
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
14 changes: 14 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
"cachedir": "^2.3.0",
"chalk": "^4.0.0",
"chokidar": "^3.4.0",
"compressible": "^2.0.18",
"cosmiconfig": "^6.0.0",
"css-modules-loader-core": "^1.1.0",
"deepmerge": "^4.2.2",
Expand Down Expand Up @@ -100,6 +101,7 @@
"@pika/plugin-ts-standard-pkg": "^0.9.1",
"@types/babel__traverse": "^7.0.7",
"@types/cacache": "^12.0.1",
"@types/compressible": "^2.0.0",
"@types/es-module-lexer": "^0.3.0",
"@types/http-proxy": "^1.17.4",
"@types/mkdirp": "^1.0.0",
Expand Down
3 changes: 2 additions & 1 deletion src/commands/dev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import cacache from 'cacache';
import chalk from 'chalk';
import chokidar from 'chokidar';
import isCompressible from 'compressible'
import detectPort from 'detect-port';
import etag from 'etag';
import {EventEmitter} from 'events';
Expand Down Expand Up @@ -117,7 +118,7 @@ const sendFile = (
}

let acceptEncoding = (req.headers['accept-encoding'] as string) || ''
if (req.headers["cache-control"]?.includes('no-transform') || ['HEAD', 'OPTIONS'].includes(req.method!)) {
if (req.headers["cache-control"]?.includes('no-transform') || ['HEAD', 'OPTIONS'].includes(req.method!) || !isCompressible(mime.contentType(ext))) {
acceptEncoding = ''
}

Expand Down

0 comments on commit 6600cf3

Please sign in to comment.