Security News
GitHub Removes Malicious Pull Requests Targeting Open Source Repositories
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
@macropygia/vite-plugin-imagemin-cache
Advanced tools
Vite plugin to compress bundle and public images using imagemin. With persistent cache.
English | 日本語
Vite plugin to compress static assets and public images using imagemin. With persistent cache.
"type": "module"
is required in the package.json of the project using this plugin.$ npm install @macropygia/vite-plugin-imagemin-cache
import { defineConfig } from 'vite'
import imageminPlugin from '@macropygia/vite-plugin-imagemin-cache'
export default defineConfig({
plugins: [
imageminPlugin({
cacheDir: '.cache',
concurrency: 4,
plugins: {
pngquant: { quality: [0.65, 1] },
mozjpeg: { quality: 85 },
}
}),
],
})
Parameter | Type | Default | Required |
---|---|---|---|
cacheDir | string | node_modules/.imagemin | No |
expireDuration | number | 864000 (10 Days) | No |
countToExpire | number | 10 | No |
concurrency | number | os.cpus().length | No |
exclude | string | string[] | No | |
plugins | object | {} | No |
asset.cachbuster | boolean | string | false | No |
asset.useCrc | boolean | (Auto) | No |
asset.preventOverwrite | boolean | false | No |
public.preventDefault | boolean | false | No |
Set the cache directory.
Cache files will delete when the following conditions are satisfied.
countToExpire
times of the build.expireDuration
seconds have passed since last used.The maximum concurrency of compressing.
Glob patterns to exclude from compression.
Imagemin plugin settings.
.png
).png
).jpg
and .jpeg
).svg
)false
, it will be disabled.plugins: {
pngquant: { speed: 1, quality: [0.6, 1.0] },
optipng: false, // Turn off
mozjpeg: { quality: 85 },
svgo: { plugins: [ ... ] },
},
Add hash as a query string to attributes that references an image in HTML.
true
, join with ?
.
/foo/bar.png
-> /foo/bar.png?<hash>
/foo/baz.svg?q=123#id
-> /foo/baz.svg?<hash>&q=123#id
string
, join with the string.
/foo/bar.png
-> /foo/bar.png<string><hash>
/foo/baz.svg?q=123#id
-> /foo/baz.svg<string><hash>&q=123#id
If set true
, the plugin process static assets in the same way as the public directory.
rollupOptions.output.assetFileNames
.
true
if [hash]
is not included in assetFileNames
.If the file with the same name exists in the output directory, skip copying from the cache.
[hash]
.emptyOutDir
is true
.Stop Vite's default copy process for the public directory and copy compressed images and the others separately.
FAQs
Vite plugin to compress bundle and public images using imagemin. With persistent cache.
The npm package @macropygia/vite-plugin-imagemin-cache receives a total of 3 weekly downloads. As such, @macropygia/vite-plugin-imagemin-cache popularity was classified as not popular.
We found that @macropygia/vite-plugin-imagemin-cache demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.