开发者

CakePHP AssetCompress: Not generating compressed files in cache folders

Has anyone here used Mark Story's Asset Compress (https://github.com/markstory/asset_compress/) plugin ?

I've followed the installation instructions to the last bit and have the plugin up and running - but it simply won't generate the combined JS files to the specified cache (cache_js) folder.

I'm using Cake 1.3 and开发者_高级运维 v0.2 of AssetCompress (the latest available download from github).

  1. The plugin has been placed in the app/plugins/asset_compress folder
  2. Cache folders - cache_js and cache_css created in WEBROOT
  3. JsMin and CssMin filters downloaded and added to app/vendors/JsMin and app/vendors/CssMin respectively
  4. Config file setup to point to the cache folders and filters
  5. Routes configured as per requirements
  6. Debug mode set to 1

My config.ini:

[Javascript]
searchPaths[] = WEBROOT/js/
searchPaths[] = WEBROOT/js/jquery/
searchPaths[] = WEBROOT/js/jquery/plugins/
stripComments = true
cacheFilePath = WEBROOT/cache_js/
cacheFiles = false
filters[] = JsMin

[Css]
searchPaths[] = WEBROOT/css/
stripComments = true
cacheFilePath = WEBROOT/cache_css/
cacheFiles = false
filters[] = CssMin

Still no output in the cache folders.

Any ideas why ?

Thanks, m^e


I did not use this plugin yet but just few comments. -sometimes minification leads to the hells (javascript errors)especially if you mimnify an already minified version -minification makes comments and license agreements disappear which makes things illegal.

I personally, do not prefer to compress assets using plugins. plugin in cakePHP by definition is a semi application not just a utility class (helper, component, behavior, or any vendor utility class) currently I am compressing the concatenated javascript files (resp css files) in the AppController by using just one function


Finally got it to work.

Turns out I was messing around with v0.2 which is what you get by default when you hit the DOWNLOAD button at the GitHub repository of Asset Compress.

You've to check out the latest version from GitHub using a git client like msysGit (if you are on Windows) and then be extra careful about where you are placing the asset inclusion commands.

Here are the steps you need to take:

  1. Place the contents of the download in a folder named asset_compress under your app's plugins folder.
  2. Include the plugin as a helper (preferably in your app_controller.php)

    public $helpers = array( 'AssetCompress.AssetCompress', );

  3. In your layout file, place the asset inclusion commands, e.g.

    $this->AssetCompress->script( filename );

  4. Just before the point where you place echo $scripts_for_layout in your layout, place the statement,

    echo $this->AssetCompress->includeJs();

...and you're good to go.

Cheers, m^e

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜