MDLeom 2022-11-06 06:47:37 +00:00
parent 2e2258f6de
commit 591b1d8713
No known key found for this signature in database
GPG Key ID: 06C236E63CBC68AA
4 changed files with 7 additions and 10 deletions

View File

@ -10,7 +10,6 @@
Yet Another Minifier for Hexo. Minify and compress HTML, JS, CSS, SVG, XML and JSON. [Other files](https://github.com/curbengh/hexo-yam/blob/ba77db0094a7c07ea9f70f010bfc15541d4105ca/index.js#L64) are also compressed. Support gzip and [brotli](https://en.wikipedia.org/wiki/Brotli) [compressions](https://en.wikipedia.org/wiki/HTTP_compression). Yet Another Minifier for Hexo. Minify and compress HTML, JS, CSS, SVG, XML and JSON. [Other files](https://github.com/curbengh/hexo-yam/blob/ba77db0094a7c07ea9f70f010bfc15541d4105ca/index.js#L64) are also compressed. Support gzip and [brotli](https://en.wikipedia.org/wiki/Brotli) [compressions](https://en.wikipedia.org/wiki/HTTP_compression).
## Table of contents ## Table of contents
- [Installation](#installation) - [Installation](#installation)
@ -103,13 +102,12 @@ minify:
- **priority** - Plugin's priority. Defaults to `10`. - **priority** - Plugin's priority. Defaults to `10`.
- **verbose** - Verbose output. Defaults to `false`. - **verbose** - Verbose output. Defaults to `false`.
- **exclude** - Exclude files. Support [wildcard](http://www.globtester.com/) pattern(s) in a string or array. - **exclude** - Exclude files. Support [wildcard](http://www.globtester.com/) pattern(s) in a string or array.
- **compress** - Compress options. - **compress** - [Compress options](https://swc.rs/docs/configuration/minification#jscminifycompress).
- **mangle** - Mangle variable names. Defaults to `true`. Pass an object to specify [mangle options](https://github.com/terser-js/terser#mangle-options). - **mangle** - Mangle variable names. Defaults to `true`. Pass an object to specify [mangle options](https://swc.rs/docs/configuration/minification#jscminifymangle).
- **output** - Output options. - **format** - [Format options](https://swc.rs/docs/configuration/minification#jscminifyformat).
- To retain comments, `output: {comments: true}`.
- **globOptions** - See [globbing](#globbing) section. - **globOptions** - See [globbing](#globbing) section.
For more options, see [Terser](https://github.com/terser-js/terser). For more options, see [SWC](https://swc.rs/docs/configuration/minification).
## SVG ## SVG

View File

@ -39,7 +39,7 @@ hexo.config.minify.js = Object.assign({
exclude: ['*.min.js'], exclude: ['*.min.js'],
compress: {}, compress: {},
mangle: true, mangle: true,
output: {}, format: {},
globOptions: { basename: true } globOptions: { basename: true }
}, hexo.config.minify.js) }, hexo.config.minify.js)

View File

@ -109,10 +109,9 @@ async function minifyJs (str, data) {
if (isMatch(path, exclude, globOptions)) return str if (isMatch(path, exclude, globOptions)) return str
// Terser/SWC doesn't like unsupported options // SWC/Terser doesn't like unsupported options
const jsOptions = Object.assign({}, options) const jsOptions = Object.assign({}, options)
delete jsOptions.enable delete jsOptions.enable
delete jsOptions.output
delete jsOptions.priority delete jsOptions.priority
delete jsOptions.verbose delete jsOptions.verbose
// Old option, retained to avoid crash when upgrading to v4 // Old option, retained to avoid crash when upgrading to v4

View File

@ -24,7 +24,7 @@ describe('js', () => {
exclude: ['*.min.js'], exclude: ['*.min.js'],
compress: {}, compress: {},
mangle: true, mangle: true,
output: {}, format: {},
globOptions: { basename: true } globOptions: { basename: true }
} }
} }