CakePHP AssetCompress:不在缓存文件夹中生成压缩文件
这里有人使用过 Mark Story 的 Asset compress (https://github.com/markstory/asset_compress/) 插件吗?
我已按照安装说明进行了最后一步操作,并启动并运行了该插件 - 但它根本不会将组合的 JS 文件生成到指定的缓存 (cache_js) 文件夹中。
我正在使用 AssetCompress 的 Cake 1.3 和 v0.2(可以从 github 下载最新版本)。
- 该插件已放置在 app/plugins/asset_compress 文件夹中
- 缓存文件夹 - 在 WEBROOT 中创建的 cache_js 和 cache_css
- JsMin 和 CssMin 过滤器下载并分别添加到 app/vendors/JsMin 和 app/vendors/CssMin
- 配置文件设置指向缓存文件夹和过滤器
- 根据要求配置的路由
- 调试模式设置为 1
我的 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
缓存文件夹中仍然没有输出。
有什么想法吗?
谢谢, 米^e
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).
- The plugin has been placed in the app/plugins/asset_compress folder
- Cache folders - cache_js and cache_css created in WEBROOT
- JsMin and CssMin filters downloaded and added to app/vendors/JsMin and app/vendors/CssMin respectively
- Config file setup to point to the cache folders and filters
- Routes configured as per requirements
- 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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我还没用过这个插件
但只有很少的评论。
-有时缩小会导致地狱(javascript错误),特别是如果你缩小已经缩小的版本
-缩小使得评论和许可协议消失,这使得事情变得非法。
我个人不喜欢使用插件来压缩资源。
cakePHP 中的插件根据定义是一个半应用程序,而不仅仅是一个实用程序类(帮助程序、组件、行为或任何供应商实用程序类)
目前,我仅使用一个函数来压缩 AppController 中的串联 javascript 文件(resp css 文件)
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
终于开始工作了。
结果我搞乱了 v0.2,这是当你点击 资产压缩的 GitHub 存储库。
您必须使用 msysGit 等 git 客户端从 GitHub 查看最新版本(如果您使用的是 Windows),然后要格外小心放置资源包含命令的位置。
以下是您需要执行的步骤:
包含该插件作为助手(最好在您的 app_controller.php 中)
公共 $helpers = 数组(
'资产压缩.资产压缩',
);
在布局文件中,放置资源包含命令,例如
$this->AssetCompress->script( filename );
在布局中放置 echo $scripts_for_layout 的位置之前,放置语句,
echo $this->AssetCompress->includeJs();
...就可以了。
干杯,
米^e
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:
Include the plugin as a helper (preferably in your app_controller.php)
public $helpers = array(
'AssetCompress.AssetCompress',
);
In your layout file, place the asset inclusion commands, e.g.
$this->AssetCompress->script( filename );
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