craft-asset-rev: rev() can't seem to find my manifest file

I’ve been troubleshooting this one for a few hours now, and I’m at the point where I just need someone to take a look at this and make sure I’m doing what I think the README is telling me to do.

I’m running a Craft CMS 3 project, and my directory structure looks like this (it’s the default structure):

project/
|--web
     |--resources
          |--app.<cachebusting-string>.css
          |--app.<cachebusting-string>.js
     |--mix-manifest.json
|--vendor
|--(etc.)

My mix-manifest.json file looks like this:

{
    "/resources/app.js": "/resources/app.<cachebusting-string>.js",
    "/resources/app.css": "/resources/app.<cachebusting-string>.css"
}

And my config/assetrev.php file looks like this:

 <?php
 return [
     '*' => [
         'strategies' => [
             'manifest' => \club\assetrev\utilities\strategies\ManifestFileStrategy::class,
             'querystring' => \club\assetrev\utilities\strategies\QueryStringStrategy::class,
             'passthrough' => function ($filename, $config) {
                 return $filename;
             },
         ],
         'pipeline' => 'manifest|querystring|passthrough',
         'manifestPath' => '/mix-manifest.json',
         'assetsBasePath' => 'resources',
         'assetUrlPrefix' => ''
     ],
     'dev' => [
         'pipeline' => 'passthrough'
     ]
 ];

And just in case there’s something I’m missing here, this is what my rev() functions look like in my index.twig file:

<link rel="stylesheet" href="{{ rev('/resources/app.css') }}" media="screen">
<script src="{{ rev('/resources/app.js') }}"></script>

I’m absolutely at a loss. I think my eyes are just crossed from staring at the same piece of code for 4 hours straight, so if anyone has some insight as to where I have misunderstood what’s supposed to be happening here, that would be great.

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 16 (2 by maintainers)

Most upvoted comments

@poopsplat I am using it on the latest 3.4.9 version and it works fine

https://github.com/mister-bk/craft-plugin-mix/blob/master/README.md

@poopsplat out of curiosity, why not use the larvel mix plugin that reads the mix-manifest files? I did so recently on a project where I used Larvel Mix.

@AlexanderSix + @scottwakefield — almost as soon as I posted that I resolved the issue, and it ended up actually being related to #25 — I removed the trailing slash from assetUrlPrefix, and added a leading slash to the rev() calls and that did the trick for me. So in the end the change was going from:

assetUrlPrefix => '/assets/dist/' + <link rel="stylesheet" href="{{ rev('styles/main.css') }}"> to assetUrlPrefix => '/assets/dist' + <link rel="stylesheet" href="{{ rev('/styles/main.css') }}">

Though it doesn’t seem like @AlexanderSix was having that same issue.

@besimhu I have been using the newest versions as they have been coming out. At this point, I’ve just disabled this code and will re-implement it when I can find out what’s going wrong.