[DEPRECATED] Laravel Mix v2/3 plugin to auto extract vendor js
Laravel Mix plugin to auto extract 3rd party dependencies as vendor.js
.
:mega: Notice: This feature has been added to Laravel Mix v4.0 now. :tada:
extract()
method which accepts an array of dependencies that you want to extract as vendor.js
node_modules
to vendor.js
file.// app.js
import Vue from 'vue';
import axios from 'axios';
vue
and axios
will be auto extracted to vendor.js
file# npm
npm install laravel-mix-auto-extract --save
# yarn
yarn add laravel-mix-auto-extract
Update your webpack.mix.js
const mix = require('laravel-mix');
// Require this package
require('laravel-mix-auto-extract');
// Your code may go here
// mix.js('./resources/assets/js/app.js', './public/js/app.js')
// mix.version()
// Call this method at last
mix.autoExtract();
Then update your blade template
<script src="{{ mix('js/manifest.js') }}"></script>
<script src="{{ mix('js/vendor.js') }}"></script>
<script src="{{ mix('js/app.js') }}"></script>
Remove any reference to extract()
method in webpack.mix.js
Here are the default options, all of them are optional.
mix.autoExtract({
vendorPath: 'js/vendor', // Don't suffix paths with `.js`
manifestPath: 'js/manifest',
excludeRegExp: /^.*\.(css|scss|sass|less|styl)$/,
generateManifest: true,
});
Paths are relative to the default output directory, usually ./public
.
Don't use autoExtract()
method along with extract()
method.
Please see CHANGELOG for more information what has changed recently.
MIT License