Closed kmgdevelopment closed 5 years ago
Hi @kgrote,
The assetBasePath
is relative to Craft base directory (or project root), so changing ../content/assets/
to content/assets/
should do the trick, assuming that your content
directory is in the same directory as your vendor
folder.
Can you give that a try and let me know how you get on?
Hi Scott,
My folder structure is:
craft/
content/
--assets/
----css/
------main.css
So I'm pretty sure I've got it right already.
Hi Kristen,
Ah, are you using Craft 2? I had recreated your setup on a fresh Craft 3 install.
Let me know and I'll take a look into it for you.
Cheers! 👍
Nope, Craft 3.0.36 / Asset Rev 6.0.2
So were you able to recreate the problem?
Hi Kristen,
Unfortunately not. I've installed fresh copies of Craft 3.0.36 and Asset Rev 6.0.2 and changed the default directory structure to:
I added
'assetsBasePath' => '../content/assets',
'assetUrlPrefix' => '{baseUrl}/assets/',
to craft/config/assetrev.php
.
Calling {{ rev('css/main.css') }}
in a template appends the query string as you would expect.
Does that configuration and setup match how you have set up your project?
OK I was editing the config.php
file in the plugin's vendor
folder rather than creating an assetrev.php
file in craft's config
folder. So that fixed the issue with the paths, but I'm still having a problem where my config variables aren't parsing.
So in my main craft/config/general.php
I've got:
return [
* => [
// global config settings
],
'local' => [
'siteUrl' => '//mysite.local'
],
];
And my craft/config/assetrev.php
:
<?php
return array(
'*' => array(
'strategies' => [
'manifest' => \club\assetrev\utilities\strategies\ManifestFileStrategy::class,
'querystring' => \club\assetrev\utilities\strategies\QueryStringStrategy::class,
'passthrough' => function ($filename, $config) {
return $filename;
},
],
'pipeline' => 'querystring|passthrough',
'manifestPath' => '',
'assetsBasePath' => '../content/assets/'
),
'local' => array(
'assetUrlPrefix' => '{siteUrl}/assets/',
)
);
But I get this as the output:
<link rel="stylesheet" href="{siteUrl}/assets/css/main.css?1547085278">
Got it!
environmentVariables
were updated to aliases
for Craft 3, and the variable syntax changed from {myVariable}
to @myVariable
.
So in my general.php
config file I need:
return [
* => [
// global config settings
],
'local' => [
'aliases' = array(
'siteUrl' => '//mysite.local'
)
],
];
And in assetrev.php
I need:
<?php
return array(
'*' => array(
'strategies' => [
'manifest' => \club\assetrev\utilities\strategies\ManifestFileStrategy::class,
'querystring' => \club\assetrev\utilities\strategies\QueryStringStrategy::class,
'passthrough' => function ($filename, $config) {
return $filename;
},
],
'pipeline' => 'querystring|passthrough',
'manifestPath' => '',
'assetsBasePath' => '../content/assets/'
),
'local' => array(
'assetUrlPrefix' => '@siteUrl/assets/',
)
);
So it was just a documentation issue. Swap out "Environment Variables" for "Aliases" and "{baseUrl}" for "@baseUrl" and you should be good.
Aha! Sorry about the outdated readme. I'll be sure to make sure it is kept up to date in future 👍
Pleased to hear that you got everything sorted out!
I'm trying to use the query string strategy but the plugin appears to be ignoring the
assetsBasePath
config variable when looking for files.My config:
My template tag:
I get this message in the log:
The plugin should be looking for the file in
../content/assets/css/main.css
but is ignoring theassetsBasePath
variable.If I do this in the template the query string is appended:
But the output path is wrong: