Registry / devops / snowpack-plugin-optimize

snowpack-plugin-optimize

JSON →
library0.5.0jsnpmunverified

A Snowpack plugin that minifies JS (via terser), CSS (via csso), and HTML (via html-minifier) for production builds. Supports source map generation/remapping, optional modulepreload injection, and TypeScript declaration files. Version 0.5.0 (last release June 2020) works with Snowpack ^2.17.1 and is in maintenance mode, as Snowpack has since been deprecated in favor of Vite. It does not bundle; for bundling the official webpack plugin is recommended.

npm install snowpack-plugin-optimize
INSTALL
IMPORT
SIG · SNOWPACK-PLUGIN-OP
S
snowpack-plugin-optimize
devopsjavascriptv0.5.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

plugin
plugins: [['snowpack-plugin-optimize', options]]
plugins: [require('snowpack-plugin-optimize')]
Always use the plugin reference as a string in the array syntax; direct require may not be resolved correctly by Snowpack.

Snowpack config enabling minification for JS, CSS, and HTML with source maps and modulepreload.

// snowpack.config.js module.exports = { plugins: [ [ 'snowpack-plugin-optimize', { minifyJs: true, minifyCss: true, minifyHtml: true, jsOptions: { sourceMap: true, compress: { ecma: 2019 }, format: { ecma: 2019 } }, cssOptions: { sourceMap: true }, htmlOptions: { collapseWhitespace: true, keepClosingSlash: true, removeComments: true }, modulePreload: true } ] ] }
Debug
Known issues
gotchaSnowpack 3+ removed support for plugin string shorthand – you must use the array syntax [name, options].
fix
Ensure your config uses the array form: ['snowpack-plugin-optimize', opt]
affects: >=0.5.0
deprecatedSnowpack itself is deprecated in favor of Vite. This plugin will not receive updates for newer build tools.
fix
Migrate to Vite and use vite-plugin-optimize or similar.
affects: >=0.0.0
gotchaThe plugin silently ignores options if the plugin string is not placed in an array; common mistake with nested configs.
fix
Always wrap options in an array: ['snowpack-plugin-optimize', { ... }]
affects: >=0.5.0
Errors
Common errors & fixes
Error: Cannot find module 'snowpack-plugin-optimize'
Plugin not installed as devDependency
fix
npm install --save-dev snowpack-plugin-optimize
TypeError: Cannot read property 'module' of undefined
Terser options not merged correctly; jsOptions may be missing or invalid
fix
Provide jsOptions as an object with sourceMap:true if source maps are enabled
Upgrade
Version history
0.5.0latest on npm
Audit
Dependencies
snowpackrequiredPeer dependency: requires Snowpack >=2.17.1 as the build tool
Agent activity
5 hits · last 30 days
node
4
Resources
snowpack-plugin-optimize — npm install snowpack-plugin-optimize · libregistry