Laravel-Mix helper for projects with complex & multi assets.

Overview

Laravel MultiMix

Laravel-Mix helper for projects with complex & multi assets.

🔥 Getting started

Since mix introduced in laravel 5.4 it is recommended to use this package for laravel >= 5.4 projects only.

Install package:

# NPM
npm install --save-dev laravel-multimix

# YARN
yarn add --dev laravel-multimix

Open your package.json and replace ugly scrips section with this:

  {
    "scripts": {
      "mix": "node node_modules/laravel-multimix/bin/mix"
    }
  }

Then you can run your tasks with this single command:

    # Usage syntax: npm mix [preset=dev] [package=app]
    
    # Example: run preset hot (with package app)
    npm mix hot
    
    # Example: run preset watch on package bootstrap
    npm mix watch bootstrap

🎌 Presets

presets are just different sets of flags and envs passed to webpack. They are basically same as default laravel package.json commands.

Available Presets

  • dev
  • watch
    • args: --watch
  • poll
    • args: --watch --watch-poll
  • hot
    • args: --hot --inline
    • entry: webpack-dev-server
  • production
    • env: production

📦 Packages

Packages are optional and available via MIX_PACKAGE env. It will do nothing by default. But is very useful when using with Utils. The philosophy behind packages is to having separate assets with different build workflow. This makes builds cleaner, faster and more efficient.

💁 Utils

Laravel MultiMix exposes some utils constant and functions.

  • MIX_PACKAGE : is same as package name argument
  • NPM : is relative path to node_modules
  • VENDOR : is relative path to resources/assets/vendor
  • output(package_name): generates path to public with this template: public/assets/{package}/
  • OUTPUT: is output for current MIX_PACKAGE

See example below for better understanding.

📚 Example

// webpack.mix.js

const {mix} = require('laravel-mix');
const {MIX_PACKAGE, NPM, VENDOR, OUTPUT, output} = require('laravel-multimix');

/*
 |--------------------------------------------------------------------------
 | Bootstrap
 | @package bootstrap
 |--------------------------------------------------------------------------
 */
if (MIX_PACKAGE === 'bootstrap') {
    // Bootstrap + RTL
    // generates public/assets/bootstrap/bootstrap.css
    mix.sass('resources/assets/sass/bootstrap.scss', OUTPUT).options({postCss: [require('postcss-rtl')()]});
}

/*
 |--------------------------------------------------------------------------
 | App
 | @package app
 |--------------------------------------------------------------------------
 */
if (MIX_PACKAGE === 'app') {
       // JS
       // generates public/assets/app/app.js
       mix.js('resources/assets/js/app.js', OUTPUT).extract([
           'jquery',
           'nprogress',
           'swiper',
           
       ]);
   
       // CSS
       // generates public/assets/app/app.css
        mix.styles([
           output('bootstrap') + 'bootstrap.css',
           NPM + 'swiper/dist/css/swiper.min.css',
           
       ], OUTPUT + 'app.css');
}

☂️ Common Issues

Reload watcher when webpack.mix.js file is udpdated
See #1

💡 Former & Related projects

🗝 License

The MIT License (MIT) - Copyright (c) 2017 Fandogh - Pooya Parsa

Comments
  • Reload watcher when webpack.mix.js file is udpdated

    Reload watcher when webpack.mix.js file is udpdated

    Not sure if this is a relative issue, but there isn't so much of a change when the webpack.mix.js file is updated while the run watch <package name> is executing (changes in the webpack file are of course in the scope of the requested package!). So you have to stop the execution of that command, make the changes to webpack file and run it again to see the changes.

    Again, not sure if this is an appropriate question or the webpack is technically not meant to change or update during watch operation.

    question 
    opened by anewage 2
  • Update dependency lodash to ^4.17.20 - autoclosed

    Update dependency lodash to ^4.17.20 - autoclosed

    WhiteSource Renovate

    This PR contains the following updates:

    | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | lodash (source) | ^4.17.11 -> ^4.17.20 | age | adoption | passing | confidence |


    Release Notes

    lodash/lodash

    v4.17.20

    Compare Source

    v4.17.16

    Compare Source

    v4.17.15

    Compare Source

    v4.17.14

    Compare Source

    v4.17.13

    Compare Source

    v4.17.12

    Compare Source


    Renovate configuration

    :date: Schedule: At any time (no schedule defined).

    :vertical_traffic_light: Automerge: Disabled by config. Please merge this manually once you are satisfied.

    :recycle: Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

    :no_bell: Ignore: Close this PR and you won't be reminded about this update again.


    • [ ] If you want to rebase/retry this PR, check this box

    This PR has been generated by WhiteSource Renovate. View repository job log here.

    opened by renovate[bot] 0
  • Update dependency lodash to v4.17.19 [SECURITY] - autoclosed

    Update dependency lodash to v4.17.19 [SECURITY] - autoclosed

    WhiteSource Renovate

    This PR contains the following updates:

    | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | lodash (source) | 4.17.11 -> 4.17.19 | age | adoption | passing | confidence |

    GitHub Vulnerability Alerts

    CVE-2019-10744

    Versions of lodash before 4.17.12 are vulnerable to Prototype Pollution. The function defaultsDeep allows a malicious user to modify the prototype of Object via {constructor: {prototype: {...}}} causing the addition or modification of an existing property that will exist on all objects.

    Recommendation

    Update to version 4.17.12 or later.

    CVE-2020-8203

    Versions of lodash prior to 4.17.19 are vulnerable to Prototype Pollution. The function zipObjectDeep allows a malicious user to modify the prototype of Object if the property identifiers are user-supplied. Being affected by this issue requires zipping objects based on user-provided property arrays.

    This vulnerability causes the addition or modification of an existing property that will exist on all objects and may lead to Denial of Service or Code Execution under specific circumstances.


    Release Notes

    lodash/lodash

    v4.17.19

    v4.17.16

    Compare Source

    v4.17.15

    Compare Source

    v4.17.14

    Compare Source

    v4.17.13

    Compare Source

    v4.17.12

    Compare Source


    Renovate configuration

    :date: Schedule: "" (UTC).

    :vertical_traffic_light: Automerge: Disabled by config. Please merge this manually once you are satisfied.

    :recycle: Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

    :no_bell: Ignore: Close this PR and you won't be reminded about this update again.


    • [ ] If you want to rebase/retry this PR, check this box

    This PR has been generated by WhiteSource Renovate. View repository job log here.

    opened by renovate[bot] 0
  • Update dependency lodash to ^4.17.11

    Update dependency lodash to ^4.17.11

    This PR contains the following updates:

    | Package | Type | Update | Change | References | |---|---|---|---|---| | lodash | dependencies | patch | ^4.17.4 -> ^4.17.11 | homepage, source |


    Release Notes

    lodash/lodash

    v4.17.11

    Compare Source

    v4.17.10

    Compare Source

    v4.17.9

    Compare Source

    v4.17.5

    Compare Source


    Renovate configuration

    :date: Schedule: At any time (no schedule defined).

    :vertical_traffic_light: Automerge: Disabled by config. Please merge this manually once you are satisfied.

    :recycle: Rebasing: Whenever PR becomes conflicted, or if you modify the PR title to begin with "rebase!".

    :no_bell: Ignore: Close this PR and you won't be reminded about this update again.


    This PR has been generated by Renovate Bot. View repository job log here.

    opened by renovate[bot] 0
  • Configure Renovate

    Configure Renovate

    Welcome to Renovate! This is an onboarding PR to help you understand and configure settings before regular Pull Requests begin.

    :vertical_traffic_light: To activate Renovate, merge this Pull Request. To disable Renovate, simply close this Pull Request unmerged.


    Detected Package Files

    • package.json (npm)

    Configuration

    :abcd: Renovate has detected a custom config for this PR. Feel free to post it to the Config Help repository if you have any doubts and would like it reviewed.

    Important: Now that this branch is edited, Renovate can't rebase it from the base branch any more. If you make changes to the base branch that could impact this onboarding PR, please merge them manually.

    What to Expect

    With your current configuration, Renovate will create 1 Pull Request:

    Update dependency lodash to ^4.17.11
    • Schedule: "at any time"
    • Branch name: renovate/all-minor-patch
    • Upgrade lodash to ^4.17.11

    :question: If you have any questions, try reading the Docs, particularly the Getting Started section. Also, you can post questions about your config in Renovate's Config Help repository.


    This PR has been generated by Renovate Bot. View repository job log here.

    opened by renovate[bot] 0
  • Dependency Dashboard

    Dependency Dashboard

    This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

    Open

    These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

    Detected dependencies

    npm
    package.json
    • lodash ^4.17.11

    • [ ] Check this box to trigger a request for Renovate to run again on this repository
    opened by renovate[bot] 0
  • Update dependency lodash to v4.17.21 [SECURITY]

    Update dependency lodash to v4.17.21 [SECURITY]

    Mend Renovate

    This PR contains the following updates:

    | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | lodash (source) | 4.17.11 -> 4.17.21 | age | adoption | passing | confidence |

    GitHub Vulnerability Alerts

    CVE-2019-10744

    Versions of lodash before 4.17.12 are vulnerable to Prototype Pollution. The function defaultsDeep allows a malicious user to modify the prototype of Object via {constructor: {prototype: {...}}} causing the addition or modification of an existing property that will exist on all objects.

    Recommendation

    Update to version 4.17.12 or later.

    CVE-2021-23337

    lodash versions prior to 4.17.21 are vulnerable to Command Injection via the template function.

    CVE-2020-8203

    Versions of lodash prior to 4.17.19 are vulnerable to Prototype Pollution. The function zipObjectDeep allows a malicious user to modify the prototype of Object if the property identifiers are user-supplied. Being affected by this issue requires zipping objects based on user-provided property arrays.

    This vulnerability causes the addition or modification of an existing property that will exist on all objects and may lead to Denial of Service or Code Execution under specific circumstances.


    Release Notes

    lodash/lodash

    v4.17.21

    Compare Source

    v4.17.20

    Compare Source

    v4.17.16

    Compare Source

    v4.17.15

    Compare Source

    v4.17.14

    Compare Source

    v4.17.13

    Compare Source

    v4.17.12

    Compare Source


    Configuration

    📅 Schedule: Branch creation - "" (UTC), Automerge - At any time (no schedule defined).

    🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.

    Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

    🔕 Ignore: Close this PR and you won't be reminded about this update again.


    • [ ] If you want to rebase/retry this PR, check this box

    This PR has been generated by Mend Renovate. View repository job log here.

    opened by renovate[bot] 0
  • How to use mix.version()

    How to use mix.version()

    Is it possible to use the versioning option with this package? I have tried but the mix-manifest.json only gets the paths of the last npm mix executed command.

    opened by hfalucas 1
  • Having nested node_modules and different build files

    Having nested node_modules and different build files

    Hello @pi0

    I've been playing around with this package, and i can relate to lot of needs.

    I do something different, abut can leverage your package very well. Maybe you want to take a look?

    Project: https://github.com/ijpatricio/laravel-mix-branches

    Live demo: https://laravel-mix-branches.laravel.pt/

    Project root has "root node_modules"

    but then application areas may have different node_modules dependecies.

    resources/assets/mix-branches has modules/packages folders. check inside.

    App is TailwindCss, while Blog is not. App is VueJs 2.5, Blog is Vue 1. (for whatever reason.. just for demo...)

    What do you think?

    opened by ijpatricio 1
Releases(v0.0.2)
Run multiple websites using the same Laravel installation while keeping tenant specific data separated for fully independent multi-domain setups, previously github.com/hyn/multi-tenant

The unobtrusive Laravel package that makes your app multi tenant. Serving multiple websites, each with one or more hostnames from the same codebase. B

Tenancy 2.4k Jan 3, 2023
Taskpm - Run multi tasks by PHP multi process

php-pkg-template Run multi tasks by PHP multi process Install composer composer require phppkg/taskpm Usage github: use the template for quick create

PHPPkg 2 Dec 20, 2021
A helper package to flash a bootstrap alert to the browser via a Facade or a helper function.

Alert Box (Laravel) A helper package to flash a bootstrap alert to the browser via a Facade or a helper function. <div class="alert alert-info fade in

Ben-Piet O'Callaghan 17 Dec 30, 2022
Cache-purge-helper - Additional instances where nginx-helper and lscache plugin should be purged.

cache-purge-helper Additional instances where nginx-helper and lscache plugin should be purged. Install Extract the zip file. Upload them to /wp-conte

Jordan 10 Oct 5, 2022
A collection of helper functions that I use across my projects.

A collection of helper functions that I use across my projects. This package includes some of the helper functions that I tend to use in all of my pro

Ryan Chandler 33 Oct 18, 2022
Laravel ecommerce package for professional, ultra fast online shops, complex B2B applications and #gigacommerce

Aimeos Laravel ecommerce package ⭐ Star us on GitHub — it helps! Aimeos is THE professional, full-featured and ultra fast e-commerce package for Larav

Aimeos 5.9k Dec 26, 2022
Output complex, flexible, AJAX/RESTful data structures.

Fractal Fractal provides a presentation and transformation layer for complex data output, the like found in RESTful APIs, and works really well with J

The League of Extraordinary Packages 3.5k Dec 26, 2022
Add internal link to your published assets.

WORK IN PROGRESS, some functionalities may be changed in the future. Add internal link to your published assets. Installation You can install the pack

Kaqaz Studio 1 Aug 9, 2022
Flow package to synchronize metadata and binary data of imported Neos.Media assets

Wwwision.AssetSync Flow package to synchronize metadata and resources of imported Neos.Media assets Installation Install this package via: composer re

Bastian Waidelich 5 Feb 7, 2022
This package provides a console command to convert dynamic JS/CSS to static JS/CSS assets.

Laravel Nova Search This package provides a console command to convert dynamic JS/CSS to static JS/CSS assets. Requirements laravel-mix v6.0+ php 7.3+

Akki Khare 3 Jul 19, 2022
Allows Filament static assets (css, js) to be served directly from /public

Filament Static Asset Handling This package aims to solve improve the static asset handling of the amazing Laravel package Filament. By default Filame

Jamie Holly 8 Dec 6, 2022
A Laravel extension for using a laravel application on a multi domain setting

Laravel Multi Domain An extension for using Laravel in a multi domain setting Description This package allows a single Laravel installation to work wi

null 658 Jan 6, 2023
Laravel Query Helper was developed for laravel 7.2+ to help you optimize sql queries

Laravel Query Helper Laravel Query Helper was developed for laravel 7.2+ to help you optimize sql queries, this package will contain all advanced SQL

Syrian Open Source 15 Nov 20, 2022
Automatic multi-tenancy for Laravel. No code changes needed.

Tenancy for Laravel — stancl/tenancy Automatic multi-tenancy for your Laravel app. You won't have to change a thing in your application's code. ✔️ No

Samuel Štancl 2.7k Jan 3, 2023
Tiny hands is a Laravel multi-tenant boilerplate with SPA and i18n.

About Tiny Hands Tiny hands is a Laravel multi-tenant boilerplate with SPA and i18n using the following technology stack: Backend Laravel 8.0 API with

Bertrand Kintanar 12 Jun 23, 2022
🧙‍♀️ Arcanist takes the pain out of building multi-step form wizards in Laravel.

Installation Arcanist requires PHP 8 and Laravel 8. composer require laravel-arcanist/arcanist Documentation You can find the full documentation here

Arcanist 378 Jan 3, 2023
Run multiple websites using the same Laravel installation while keeping tenant specific data separated for fully independent multi-domain setups.

Tenancy for Laravel Enabling awesome Software as a Service with the Laravel framework. This is the successor of hyn/multi-tenant. Feel free to show su

Tenancy 1.1k Dec 30, 2022
Multi theme support for Laravel application

Multi theme support for Laravel application This Laravel package adds multi-theme support to your application. It also provides a simple authenticatio

QiroLab 287 Dec 29, 2022
Support multi theme for Laravel application

Very short description of the package This is where your description should go. Try and limit it to a paragraph or two, and maybe throw in a mention o

Ephraïm SEDDOR 1 Dec 1, 2021