sathoro/Compressor

语言: PHP

git: https://github.com/sathoro/Compressor

Craft CMS插件可自动组合,缩小和缓存CSS和JS资源。
Craft CMS plugin to automatically combine, minify, and cache-break your CSS and JS resources.
README.md (中文)

工艺,压缩机

Craft CMS扩展,可自动组合,缩小和缓存CSS和JS资源。

用法示例:

{{ craft.compressor.css([
    '/style/style.css',
    '/style/media-queries.css',
    '/style/fontello.css',
    'http://fonts.googleapis.com/css?family=Lato:400,700,900',
    '/style/flexslider.css'
]) }}

{{ craft.compressor.js([
    '/scripts/jquery.js',
    '/scripts/ddsmoothmenu.js',
    '/scripts/selectnav.js',
    '/scripts/jquery.flexslider.js',
    '/scripts/scripts.js'
]) }}

将输出:

<link rel="stylesheet" href="http://example.com/cache/cached.5fe383065467625b28499c2b885d60fa.css">
<script src="http://example.com/cache/cached.0c4a14a00d89f6a600a931c274ad16ba.js"></script>

更新或删除任何CSS或JS文件时,将使用新的哈希和文件名生成文件。

建立

  • 下载此存储库,将文件夹重命名为'compressor'并上传到craft / plugins目录。
  • 在public / cache创建一个'cache'目录,并确保它可以被Apache写入。
  • 请享用!

本文使用googletrans自动翻译,仅供参考, 原文来自github.com

en_README.md

Craft-Compressor

A Craft CMS extension to automatically combine, minify, and cache-break your CSS and JS resources.

Example usage:

{{ craft.compressor.css([
    '/style/style.css',
    '/style/media-queries.css',
    '/style/fontello.css',
    'http://fonts.googleapis.com/css?family=Lato:400,700,900',
    '/style/flexslider.css'
]) }}

{{ craft.compressor.js([
    '/scripts/jquery.js',
    '/scripts/ddsmoothmenu.js',
    '/scripts/selectnav.js',
    '/scripts/jquery.flexslider.js',
    '/scripts/scripts.js'
]) }}

Will output:

<link rel="stylesheet" href="http://example.com/cache/cached.5fe383065467625b28499c2b885d60fa.css">
<script src="http://example.com/cache/cached.0c4a14a00d89f6a600a931c274ad16ba.js"></script>

When any CSS or JS file is updated or removed the file will be generated with a new hash and filename.

Setup

  • Download this repository, rename the folder to 'compressor' and upload to craft/plugins directory.
  • Create a 'cache' directory at public/cache and make sure it is writable by Apache.
  • Enjoy!