mister-bk / craft-mix

Helper plugin for Laravel Mix in Craft CMS templates
MIT License
2 stars 2 forks source link
craft craft-plugin craft2 craftcms laravel-mix mix

Craft Mix Logo

Helper plugin for Laravel Mix in Craft CMS templates.

Requirements

This plugin requires Craft CMS 2.5.0 or later.

Installation

To install the plugin, follow these instructions.

  1. Download the latest release from here.

  2. Unzip the file and place the mix directory into your craft/plugins directory.

  3. 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:

NOTE: Both Public Path and Asset Path get trimmed to enabled all kind of path combinations. Here are some examples:

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

Usage

Find a versioned CSS file.

<link rel="stylesheet" href="https://github.com/mister-bk/craft-mix/blob/master/{{ mix('css/main.css') }}">

Find a versioned JavaScript file.

<script src="https://github.com/mister-bk/craft-mix/raw/master/{{ 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.