我正在尝试使用cfstatic.在我的index.cfm中,我只使用cfstatic添加green.css,cfstatic应该只添加green.css的最小化版本,所以我的h1文本<h1>I should be Green</h1>应该是绿色.但cfstatic正在添加green.css和red.css.我错过了配置吗?
的Application.cfc
component output="false"{
This.name = "testing";
This.sessionManagement = true;
This.sessionTimeout = CreateTimeSpan(1, 23, 59, 59);
This.mappings["/org"] = expandpath('.')&'\org';
function onRequestStart(){
application.cfstatic = CreateObject( 'org.cfstatic.CfStatic' )
.init( staticDirectory = ExpandPath('./assets'),
staticUrl = "/cfstatic/assets/"
);
}
}
Run Code Online (Sandbox Code Playgroud)
Index.cfm
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Test</title>
<cfscript>
application.cfstatic.include( '/css/green.css',true );
</cfscript>
<cfoutput>#application.cfstatic.renderIncludes('css')#</cfoutput>
</head>
<body>
<h1>I should be Green</h1>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
Green.css
/* This is assets/css/green.css */
h1 {color:green;}
Run Code Online (Sandbox Code Playgroud)
Red.css
/* This is assets/css/red.css */ …Run Code Online (Sandbox Code Playgroud)