Socket
Socket
Sign inDemoInstall

laravel-mix-auto-extract

Package Overview
Dependencies
0
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    laravel-mix-auto-extract

Laravel Mix plugin to auto extract 3rd party dependencies as vendor.js.


Version published
Weekly downloads
47
decreased by-31.88%
Maintainers
1
Install size
6.20 kB
Created
Weekly downloads
 

Readme

Source

Laravel Mix Auto Extract Vendors Plugin

downloads npm-version github-tag license

Laravel Mix plugin to auto extract 3rd party dependencies as vendor.js.

What was the problem?

  • Laravel Mix already has a extract() method which accepts an array of dependencies that you want to extract as vendor.js
  • Whenever you install a new package, you also need to update this list to make it work.
  • Read more on this issue

How does this plugin solve above issue?

  • This plugin will auto extract all js dependencies coming from node_modules to vendor.js file.
  • You just need to reference them in your code somewhere. For example:
// app.js
import Vue from 'vue';
import axios from 'axios';
  • Now vue and axios will be auto extracted to vendor.js file

Requirements

Installation

# npm
npm install laravel-mix-auto-extract --save

# yarn
yarn add laravel-mix-auto-extract

Usage

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

Configuration Options

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.

:warning: Caution

Don't use autoExtract() method along with extract() method.

Changelog

Please see CHANGELOG for more information what has changed recently.

License

MIT License

Keywords

FAQs

Last updated on 30 Nov 2018

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc