mister-bk / craft-plugin-mix

Helper plugin for Laravel Mix in Craft CMS templates

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

I think I'm missing something here ...

ryanfoote opened this issue · comments

... hitting Enter prematurely isn't what I'm missing. :)

As far as I can tell, Laravel Mix and this plugin are installed correctly & running, however the output in the browser suggests it isn't loading in versioned assets.

In a Twig template I have:

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

Which outputs the following into the browser:

<link rel="stylesheet" href="/assets/css/home.css">

That's not loading in the versioned asset, right?

My mix-manifest.json looks like this:

{ "/dist/web/assets/css/app.css": "/dist/web/assets/css/app.css?id=a13f60b345423483fe2b", "/dist/web/assets/css/home.css": "/dist/web/assets/css/home.css?id=19e2171da258b1e4ae32" }

Shouldn't the browser output look like this instead?

<link rel="stylesheet" href="/assets/css/home.css?id=19e2171da258b1e4ae32">

As far as I can tell from your description your Public Path may be wrong.
Go to Settings → Plugins → Mix in the Craft Control Panel and set the Public Path to dist/web.

See the configuration section in the README for more information about setting the correct Public Path and Asset Path.

I made that edit, with the same results. Here's where my config/various paths sit now:

Mix Config

let mix = require('laravel-mix');
mix.setPublicPath('./dist/web/');
mix.sass('src/app.scss', 'dist/web/assets/css/').sass('src/home.scss', 'dist/web/assets/css/').version();

mix-manifest.json (found at /dist/web/mix-manifest.json)

{
    "/assets/css/app.css": "/assets/css/app.css?id=a13f60b345423483fe2b",
    "/assets/css/home.css": "/assets/css/home.css?id=19e2171da258b1e4ae32"
}

Plugin Public Path
dist/web

Plugin Asset Path
assets

Also, this is running on Craft 3.0.0-RC14.

Thanks for the help!

You either need to update the path you use in the mix.setPublicPath() to ./dist/web/assets/ to use css/home.css as key in the mix() function or use assets/css/home.css as key.

Solved it ... My Plugin Public Path needed to be set to only web, as dist is already included in CRAFT_BASE_PATH.

Thanks for your help.