我对 Assets 类有一些问题来缩小和组合我的 css 和 js。我有这个插件广告,它似乎可以正常工作:
class Plugin_Theme_Assets extends Plugin
{
/**
* combine and insert multiple js files
*
* usage:
* { theme_assets:js_files files="file1.js,file2.js" }
*/
function js_files()
{
$files = $this->attribute('files');
preg_match_all('/[\w-\.]+\.js/i', $files, $files_a);
foreach($files_a[0] as $file)
{
Asset::js($file);
}
return Asset::render_js();
}
/**
* combine and insert multiple css files
*
* usage:
* { theme_assets:css_files files="file1.css,file2.css" }
*/
function css_files()
{
$files = $this->attribute('files');
preg_match_all('/[\w-\.]+\.css/i', $files, $files_a);
foreach($files_a[0] as $file)
{
Asset::css($file);
}
return Asset::render_css();
}
}
这是我的 .htaccess 文件,你可以看到我取消了 SetEnv 的注释:
# Multiple Environment config
# Set this to development, staging or production
SetEnv PYRO_ENV production
<IfModule mod_rewrite.c>
# Make sure directory listing is disabled
Options +FollowSymLinks -Indexes
RewriteEngine on
# NOTICE: If you get a 404 play with combinations of the following commented out lines
#AllowOverride All
RewriteBase /
# Restrict your site to only one domain
# !important USE ONLY ONE OPTION
# Option 1: To rewrite "www.domain.com -> domain.com" uncomment the following lines.
RewriteCond %{HTTPS} !=on
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
# Option 2: To rewrite "domain.com -> www.domain.com" uncomment the following lines.
#RewriteCond %{HTTPS} !=on
#RewriteCond %{HTTP_HOST} !^www\..+$ [NC]
#RewriteCond %{HTTP_HOST} (.+)$ [NC]
#RewriteRule ^(.*)$ http://www.%1/$1 [R=301,L]
# Remove index.php from URL
#RewriteCond %{HTTP:X-Requested-With} !^XMLHttpRequest$
#RewriteCond %{THE_REQUEST} ^[^/]*/index\.php [NC]
#RewriteRule ^index\.php(.*)$ $1 [R=301,NS,L]
# Keep people out of codeigniter directory and Git/Mercurial data
RedirectMatch 403 ^/(system\/cms\/cache|system\/codeigniter|\.git|\.hg).*$
# Send request via index.php (again, not if its a real file or folder)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
<IfModule mod_php5.c>
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
<IfModule !mod_php5.c>
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>
</IfModule>
所以,如果我是对的,那么 PYRO_ENV 现在是“生产”。
如果我刷新我的页面,css 和 js 文件不会被缩小并组合成一个文件......这是插件返回的内容
<link href="http://example:8888/addons/default/themes/mytheme/css/nivo-slider.css" rel="stylesheet" type="text/css" />
<link href="http://example:8888/addons/default/themes/mytheme/css/default.css" rel="stylesheet" type="text/css" />
你能帮我么?