CakePHP AssetCompress:不在缓存文件夹中生成压缩文件

发布于 2024-10-06 17:56:25 字数 957 浏览 0 评论 0原文

这里有人使用过 Mark Story 的 Asset compress (https://github.com/markstory/asset_compress/) 插件吗?

我已按照安装说明进行了最后一步操作,并启动并运行了该插件 - 但它根本不会将组合的 JS 文件生成到指定的缓存 (cache_js) 文件夹中。

我正在使用 AssetCompress 的 Cake 1.3 和 v0.2(可以从 github 下载最新版本)。

  1. 该插件已放置在 app/plugins/asset_compress 文件夹中
  2. 缓存文件夹 - 在 WEBROOT 中创建的 cache_js 和 cache_css
  3. JsMin 和 CssMin 过滤器下载并分别添加到 app/vendors/JsMin 和 app/vendors/CssMin
  4. 配置文件设置指向缓存文件夹和过滤器
  5. 根据要求配置的路由
  6. 调试模式设置为 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).

  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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

神经大条 2024-10-13 17:56:26

我还没用过这个插件
但只有很少的评论。
-有时缩小会导致地狱(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

溇涏 2024-10-13 17:56:26

终于开始工作了。

结果我搞乱了 v0.2,这是当你点击 资产压缩的 GitHub 存储库

您必须使用 msysGit 等 git 客户端从 GitHub 查看最新版本(如果您使用的是 Windows),然后要格外小心放置资源包含命令的位置。

以下是您需要执行的步骤:

  1. 将下载的内容放入应用插件文件夹下名为 asset_compress 的文件夹中。
  2. 包含该插件作为助手(最好在您的 app_controller.php 中)

    公共 $helpers = 数组(
    '资产压缩.资产压缩',
    );

  3. 在布局文件中,放置资源包含命令,例如

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

  4. 在布局中放置 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:

  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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文