Why does minified file equal to a non-minified?
const { mix } = require('laravel-mix');
mix.styles([
'public/some.css',
'public/thing.css',
], 'public/css/index.css');
mix.minify('public/css/index.css');
When running npm run production
, sizes are 128kB (both compressed)
Asset Size Chunks Chunk Names
mix.js 511 bytes 0 [emitted] mix
/css/index.css 128 kB [emitted]
/css/index.min.css 128 kB [emitted]
When running npm run dev
, both files are of the same size and it is 160 kB
, i.e. both are non-minified. How come a minified version is dependent not upon a min
suffix, but on a dev\prod option?
Overview. Minification refers to the process of removing unnecessary or redundant data without affecting how the resource is processed by the browser - e.g. code comments and formatting, removing unused code, using shorter variable and function names, and so on.
How Minification Works. Minification works by analyzing and rewriting the text-based parts of a website to reduce its overall file size. Minification extends to scripts, style sheets, and other components that the web browser uses to render the site. Minification is performed on the web server before a response is sent ...
By stripping unnecessary data from the CSS code, minification helps the browser download and process these files faster, increasing page performance and improving user experience.
Minification is the process of minimizing code and markup in your web pages and script files. It's one of the main methods used to reduce load times and bandwidth usage on websites. Minification dramatically improves site speed and accessibility, directly translating into a better user experience.
As from this laravel-mix issue Jeffrey points out that minification only happens in production mode. So to minify your css files, you can have:
mix.styles([
'public/some.css',
'public/thing.css',
], 'public/css/index.css')
Then running the following will concatenate and minify your files.
$ npm run production
Works for
([email protected])
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With