PHPackages                             delaneymethod/craft-mix - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Templating &amp; Views](/categories/templating)
4. /
5. delaneymethod/craft-mix

ActiveCraft-plugin[Templating &amp; Views](/categories/templating)

delaneymethod/craft-mix
=======================

Helper plugin for Laravel Mix in Craft CMS templates.

4.0.0(4y ago)61.9kMITPHPPHP ^8.0.2

Since Sep 5Pushed 4y agoCompare

[ Source](https://github.com/delaneymethod/craft-mix)[ Packagist](https://packagist.org/packages/delaneymethod/craft-mix)[ RSS](/packages/delaneymethod-craft-mix/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (9)Dependencies (4)Versions (11)Used By (0)

 [![Craft Mix Logo](https://github.com/delaneymethod/craft-mix/raw/master/resources/img/craft-mix.png)](https://github.com/delaneymethod/craft-mix/blob/master/resources/img/craft-mix.png)

 Helper plugin for [Laravel Mix](https://github.com/JeffreyWay/laravel-mix/) in [Craft CMS](https://github.com/craftcms/cms/) templates.

 [ ![Total Downloads](https://camo.githubusercontent.com/3b49e7ed25df1801a55a7fb060603a3f728024f6ead1ad5e97d6b95d7fe85717/68747470733a2f2f706f7365722e707567782e6f72672f64656c616e65796d6574686f642f63726166742d6d69782f642f746f74616c2e737667) ](https://packagist.org/packages/delaneymethod/craft-mix/) [ ![Latest Stable Version](https://camo.githubusercontent.com/5d54cb56a32523ddb95bae8a26511749d27d1501c5cd136217de9d18ba0ceb6b/68747470733a2f2f706f7365722e707567782e6f72672f64656c616e65796d6574686f642f63726166742d6d69782f762f737461626c652e737667) ](https://packagist.org/packages/delaneymethod/craft-mix/) [ ![License](https://camo.githubusercontent.com/7f624115fc6ff86487c93bd2ae471eceb8e8f86cc01a041a4c57c48dad83ba2a/68747470733a2f2f706f7365722e707567782e6f72672f64656c616e65796d6574686f642f63726166742d6d69782f6c6963656e73652e737667) ](https://packagist.org/packages/delaneymethod/craft-mix/)

Requirements
------------

[](#requirements)

- Craft CMS 3.7+
- PHP
- Node.js 6+

Installation
------------

[](#installation)

To install the plugin, follow these instructions.

1. Open your terminal and go to your Craft project:

```
cd /path/to/project
```

2. Then tell Composer to load the plugin:

```
composer require delaneymethod/craft-mix
```

3. In the Craft Control Panel, go to Settings → Plugins and click the "Install" button for **Craft Mix**.
4. Create a `package.json` file with the following contents to install Laravel Mix dependencies and configure asset build tasks.

```
{
	"private": true,
	"scripts": {
		"dev": "npm run development",
		"development": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
		"watch": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --watch --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
		"watch-poll": "npm run watch -- --watch-poll",
		"hot": "cross-env NODE_ENV=development node_modules/webpack-dev-server/bin/webpack-dev-server.js --inline --hot --config=node_modules/laravel-mix/setup/webpack.config.js",
		"prod": "npm run production",
		"production": "cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js"
	},
	"devDependencies": {
		"cross-env": "^7.0.3",
		"laravel-mix": "^6.0.41"
	}
}
```

Install the Node.js dependencies using `npm` or `yarn`.

```
npm install # OR yarn install
```

Configuration
-------------

[](#configuration)

To configure Craft Mix go to Settings → Plugins → Craft 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

To demonstrate usage of the plugin, let's imagine a project with the following directory structure.

```
...
assets/
  js/
    global.js
  scss/
    global.scss
web/
  assets/
    js/
    css/
...

```

Create a `webpack.mix.js` file at the root of your project to configure Laravel Mix for building your assets. See the [Laravel Mix](https://laravel.com/docs/5.5/mix) documentation for configuration details and more options. Be sure to configure the `publicPath` option to point at the directory from which you will serve static assets (images, fonts, javascript and CSS). Here's an example configuration as a starting point that would work with the previously described project structure:

```
const del = require('del');
const { mix } = require('laravel-mix');

del(['web/assets/**', '!web/assets']);

mix.setPublicPath('web/assets');

if (mix.inProduction) {
    mix.disableNotifications();
}

if (!mix.inProduction) {
	mix.sourceMaps();
}

mix.options({
	processCssUrls: false
});

mix.sass('assets/sass/global.scss', 'web/assets/css/global.css');

mix.js('assets/js/global.js', 'web/assets/js/global.js');

mix.copy('assets/fonts', 'web/assets/fonts');

mix.copy('assets/img', 'web/assets/img');

mix.version();
```

Usage
-----

[](#usage)

The primary purpose of this plugin is to provide template helpers that translate between a known path to your build assets and the real path to the assets after they have been built (which varies depending on the build mode). There are three main ways you can use Mix from Twig templates in CraftCMS:

```
{# Twig Filter #}

{# Twig Function #}

{# CraftCMS Variable #}

{{ craft.mix.withTag(\'css/global.css\') | raw }}

// include the content of a versioned file inline.
{{ craft.mix.withTag(\'css/global.css\', true) | raw }}
```

There are a handful of different modes in which you can run Mix and the plugin will work differently in each mode, as described in the following sections.

### Dev Mode

[](#dev-mode)

Dev mode will build your assets to target a development environment. Depending on how you've configured Mix, this may bypass certain build instructions intended only for the production environment. In the example `webpack.mix.js` file, we are only versioning assets in production mode for cache busting or similar use cases. You can build the assets for developer mode by using the `npm` script we added in our `package.json` file:

```
npm run dev
```

### Watch Mode

[](#watch-mode)

Functions just like Dev Mode except Mix will continue running as a foreground process through NodeJS and building assets as changes to the source files are detected.

```
npm run watch
```

### Hot Module Replacement Mode

[](#hot-module-replacement-mode)

Builds your assets and runs the Webpack dev server to allow [Hot Module Replacement](https://webpack.js.org/concepts/hot-module-replacement/). It works very similarly to what is described in the [Laravel Mix](https://github.com/JeffreyWay/laravel-mix/blob/master/docs/hot-module-replacement.md) documentation. To run in HMR mode, run the following command:

```
npm run hot
```

### Production Mode

[](#production-mode)

or bundle your assets for production

```
npm run production
```

Credits
-------

[](#credits)

- [Sean Delaney](https://github.com/seandelaney)

About DelaneyMethod
-------------------

[](#about-delaneymethod)

DelaneyMethod are a Full-Stack Web Development Agency with a no-nonsense, get it done attitude with a proven track record for delivering their part of a project. Learn more about us on [our website](http://www.delaneymethod.com).

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE) for more information.

###  Health Score

35

—

LowBetter than 80% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity24

Limited adoption so far

Community2

Small or concentrated contributor base

Maturity74

Established project with proven stability

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~189 days

Recently: every ~27 days

Total

10

Last Release

1470d ago

Major Versions

1.0.7 → 4.0.02022-05-09

### Community

Maintainers

![](https://www.gravatar.com/avatar/cfb4e92a4d0600764dcbc0058a37dc46627428e876e3bf806e398a5f1ad1f283?d=identicon)[hello@delaneymethod.com](/maintainers/hello@delaneymethod.com)

---

Tags

laravelcmsyii2Craftcraftcmscraft-pluginmixcraft4delaneymethodcraft-mix

### Embed Badge

![Health badge](/badges/delaneymethod-craft-mix/health.svg)

```
[![Health](https://phpackages.com/badges/delaneymethod-craft-mix/health.svg)](https://phpackages.com/packages/delaneymethod-craft-mix)
```

###  Alternatives

[verbb/footnotes

Adds a footnotes feature to CKEditor fields and Twig templates.

213.3k](/packages/verbb-footnotes)[trendyminds/molecule

Grab Twig components, CSS and JS files outside the primary template folder

2010.7k](/packages/trendyminds-molecule)[vierbeuter/craft-footnotes

Adds a footnotes feature to CKEditor fields and Twig templates.

212.7k](/packages/vierbeuter-craft-footnotes)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
