I am using laravel-mix
, and this is my webpack.mix.js
:
const mix = require('laravel-mix');
mix.version();
mix.js('resources/js/app.js', 'public/js').extract();
if (mix.inProduction()) {
mix.minify('public/js/vendor.js');
}
In production I want to use the minified version of vendor.js
.
In my blade template:
<script src="{{ mix('js/vendor.js') }}"></script>
In development it works as expected. But in production laravel-mix
doesn't include my minified version. The minified version is loaded only if I specify it explicitly:
<script src="{{ mix('js/vendor.min.js') }}"></script>
How to include the correct version of the file without changing templates?
Laravel Mix automatically minifies .js
files in production.
This means your vendor.js
is already minified in a production environment so there is no need to generate a separate vendor.min.js
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.