Registry / devops / laravel-mix-views-minifier

laravel-mix-views-minifier

JSON →
library2.0.1jsnpmunverified

A Laravel Mix extension that minifies Blade or other template files using HTMLMinifier. Current stable version is 2.0.1, released in 2020, with no recent updates. It wraps html-minifier and integrates into Laravel Mix's build pipeline via mix.minTemplate(). Unlike generic minifiers, it is specifically designed for Laravel's storage/framework/views directory and automatically applies only in production. Note: requires Laravel Mix and Node.js, and is unmaintained since 2020.

npm install laravel-mix-views-minifier
INSTALL
IMPORT
SIG · LARAVEL-MIX-VIEWS-
L
laravel-mix-views-minifier
devopsjavascriptv2.0.1
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.

mix.minTemplate
mix.minTemplate = require('laravel-mix-views-minifier')
import mix from 'laravel-mix'; import minTemplate from 'laravel-mix-views-minifier'
This package is CommonJS-only and attaches a method to the mix object. ES import syntax does not work directly.
mix
let mix = require('laravel-mix')
import mix from 'laravel-mix'
Laravel Mix's official API uses CommonJS require. ES imports may cause issues with mixin extensions.
mix.minTemplate
mix.minTemplate(source, output, options?)
mix.minTemplate({source: '...', output: '...'})
The function expects two positional string arguments (source glob, output directory) and an optional options object. Passing an object is incorrect.

Installs the package, attaches minTemplate to mix, and minifies all compiled Blade templates in production with custom HTMLMinifier options.

// webpack.mix.js let mix = require('laravel-mix'); mix.minTemplate = require('laravel-mix-views-minifier'); if (mix.inProduction()) { mix.minTemplate('storage/framework/views/*.php', 'storage/framework/views/', { collapseWhitespace: true, removeComments: true }); }
Debug
Known issues
deprecatedPackage is deprecated: Repository archived by owner on Jul 28, 2020. No updates for Laravel Mix 6+.
fix
Consider using laravel-mix-template-minifier or a custom webpack plugin for newer Mix versions.
affects: >=2.0.0
gotchaRequires manual installation of html-minifier as it is listed as a devDependency but may not be auto-installed in some setups.
fix
Run: npm install --save-dev html-minifier
affects: >=2.0.0
breakingVersion 2.0.0 changed the API from mix.minTemplate(source, output) to also accept an options object as third argument. Invalid options cause silent failure.
fix
Update usage to pass options as third argument if needed.
affects: >=2.0.0
gotchaOnly works with Laravel Mix >=4 and <6. Mix 6 uses webpack 5 which may cause incompatibilities.
fix
Check Mix version; for Mix 6, use an alternative or fork the package.
affects: >=1.0.0
Errors
Common errors & fixes
Error: Cannot find module 'laravel-mix-views-minifier'
Package not installed or npm install failed.
fix
Run: npm install --save-dev laravel-mix-views-minifier
TypeError: mix.minTemplate is not a function
The assignment mix.minTemplate = require(...) is missing or placed after mix is accessed.
fix
Add mix.minTemplate = require('laravel-mix-views-minifier'); before using mix.minTemplate().
Error: html-minifier not found
html-minifier is not installed as a dependency.
fix
Run: npm install --save-dev html-minifier
Upgrade
Version history
2.0.1latest on npm
Audit
Dependencies
laravel-mixrequiredLaravel Mix is required to use this extension; it provides the mix variable and build pipeline.
html-minifierrequiredUnderlying dependency for template minification; installed automatically by npm.
Agent activity
7 hits · last 30 days
node
4
Resources
laravel-mix-views-minifier — npm install laravel-mix-views-minifier · libregistry