Skip to content

Commit

Permalink
feat: support for an output suffix which is appended to the compresse…
Browse files Browse the repository at this point in the history
…d file name

Fixes alloc#12
  • Loading branch information
Artur- committed Nov 9, 2021
1 parent 5b874d5 commit 34a3172
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ type PluginOptions = {
* optionally `clean-css`.
*/
minifyHtml?: HtmlMinifyOptions | true
/**
* Suffix to add to compressed file instead of overwriting.
*/
outputSuffix?: string
}

const mtimeCache = new Map<string, number>()
Expand Down Expand Up @@ -274,6 +278,7 @@ export default (opts: PluginOptions = {}): Plugin[] => {
await fsp.unlink(filePath)
name = path.relative(outRoot, (filePath = newFilePath))
}
filePath += opts.outputSuffix
await fsp.writeFile(filePath, content)
compressed.set(name, 1 - content.byteLength / oldSize)
}
Expand Down

0 comments on commit 34a3172

Please sign in to comment.