Helper plugin for Laravel Mix in Craft CMS templates
Clone or download
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
resources/img Initial commit Apr 21, 2017
src Use registerTwigExtension() Jul 20, 2018
.gitignore Initial commit Apr 21, 2017
CHANGELOG.md v1.5.2 Jul 20, 2018
LICENSE.md Update copyright year Jan 16, 2018
README.md Use „badgen.net“ for badges and order them by priority Aug 7, 2018
composer.json v1.5.2 Jul 20, 2018

README.md

Craft Mix Logo

Helper plugin for Laravel Mix in Craft CMS templates.

Latest Stable Version Total Downloads License

Requirements

This plugin requires Craft CMS 3.0.0-RC1 or later.

Installation

To install the plugin, follow these instructions.

  1. Open your terminal and go to your Craft project:
cd /path/to/project
  1. Then tell Composer to load the plugin:
composer require misterbk/mix
  1. In the Craft Control Panel, go to Settings → Plugins and click the "Install" button for Mix.

Configuration

To configure Mix go to Settings → Plugins → Mix in the Craft Control Panel.

The available settings are:

  • Public Path - The path of the public directory containing the index.php
  • Asset Path - The path of the asset directory where Laravel Mix stores the compiled files

NOTE: Both Public Path and Asset Path get trimmed to allow all kind of path combinations.

  • /web/ + /assets//web/assets/
  • web + assets/web/assets/
  • / + assets/assets/
  • /web + //web/

Usage

Find a versioned CSS file.

<link rel="stylesheet" href="{{ mix('css/main.css') }}">

Find a versioned JavaScript file.

<script src="{{ mix('js/main.js') }}"></script>

Lazily find a versioned file and build the tag based on the file extension.

{{ craft.mix.withTag('js/main.js') | raw }}

Alternatively include the content of a versioned file inline.

{{ craft.mix.withTag('css/main.css', true) | raw }}

License

Craft Mix is open-sourced software licensed under the MIT license.