自动化 - CSS 和 CSS JS 最小化和合并文件

发布于 2025-01-08 04:40:02 字数 2921 浏览 1 评论 0原文

编辑:我想构建一个 ANT 脚本并使用 YUI 我想压缩(缩小)项目中的所有 css 文件和 JavaScript 文件并将其制作为单个文件。

就像这个人所做的http://heliologue。 com/2008/09/22/using-yui-compressor-in-a-web-project/

但我不知道如何编写 ANT 脚本,甚至不知道如何构建 build.xml 等文件。

JSF是使用的服务器技术,它包含1个css文件和1个javascript文件到基于浏览器渲染的html页面中。 (例如:ie将获取master_ie.css,master_ie.js;firefox将获取master_ff.css,master_ff.js)

但是css和js文件是用idk编写的如何解释参见示例CSS和JS主文件片段

CSS:

@import './../core/v2.3-global.css';
@import './../core/v2.3-elements-default.css';
@import './../layout/v2.3-layout.css';
@import './../app/v2.3-template-default.css';
@import './../app/v2.3-header.css';
@import './../app/v2.3-leftnav.css';
@import './../app/v2.3-popup.css';
@import './../app/v2.3-footer.css';
@import './../app/v2.3-something-provision-default.css';
@import './../app/v2.3-old-data-grid.css';
@import './../app/v2.3-header-info-container.css';
@import './../app/v2.3-data-summary-default.css';
@import './../app/v2.3-button.css';
@import './../app/v2.3-template-firefox.css';
@import './../core/v2.3-elements-firefox.css';
@import './../app/v2.3-oneclick-provision-firefox.css';
@import './../app/v2.3-data-summary-firefox.css';
@import './../app/v2.3-layout-firefox.css';
@import './../app/v2.3-tree.css' ;
@import './../app/v2.3-extended-datatable-firefox.css';
@import './../app/v2.3-change-cloud-default.css';
@import './../app/v2.3-menu-default.css';
@import './../app/v2.3-user-summary-default.css';
@import './../app/v2.3-user-summary-firefox.css';
@import './../app/v2.3-recent-task-firefox.css';

JS:

document.write("<script type='text/javascript' src='../script/jhashtable.js'></script>");
document.write("<script type='text/javascript' src='../script/action-menu/jquery-top-menu.js'></script>");
document.write("<script type='text/javascript' src='../script/jquery.treeview.js'></script>");
document.write("<script type='text/javascript' src='../script/action-menu/top-menu-impl.js'></script>");
document.write("<script type='text/javascript' src='../script/popup-modal-dialog.js'></script>");
document.write("<script type='text/javascript' src='../script/navigationSideBar.js'></script>");
document.write("<script type='text/javascript' src='../script/action-menu/action-menu-script.js'></script>");
document.write("<script type='text/javascript' src='../script/appUiComponents.js'></script>");
document.write("<script type='text/javascript' src='../script/app-ui-validator.js'></script>");

如果你能慢慢地向我解释,就像我是一个 10 岁的孩子一样,那真的会有帮助。

EDIT2:(找到解决方案) 使用 JSF -> http://code.google.com/p/capsule/ 使用 ANT ->见下文

EDIT: I want to build an ANT script and using YUI i want to compress (minify) all the css files and JavaScript files in a project AND make it into a single file.

like this guy does http://heliologue.com/2008/09/22/using-yui-compressor-in-a-web-project/

but i don't know how to write ANT scripts or even scructure the build.xml and other files.

JSF is the server technology used and it includes 1 css file and 1 javascript file into the rendered html page based on the browser. (example: ie will get master_ie.css, master_ie.js; firefox will get master_ff.css, master_ff.js)

but the css and js file are written in a idk how to explain it way see the sample CSS and JS snippet of the master file

CSS:

@import './../core/v2.3-global.css';
@import './../core/v2.3-elements-default.css';
@import './../layout/v2.3-layout.css';
@import './../app/v2.3-template-default.css';
@import './../app/v2.3-header.css';
@import './../app/v2.3-leftnav.css';
@import './../app/v2.3-popup.css';
@import './../app/v2.3-footer.css';
@import './../app/v2.3-something-provision-default.css';
@import './../app/v2.3-old-data-grid.css';
@import './../app/v2.3-header-info-container.css';
@import './../app/v2.3-data-summary-default.css';
@import './../app/v2.3-button.css';
@import './../app/v2.3-template-firefox.css';
@import './../core/v2.3-elements-firefox.css';
@import './../app/v2.3-oneclick-provision-firefox.css';
@import './../app/v2.3-data-summary-firefox.css';
@import './../app/v2.3-layout-firefox.css';
@import './../app/v2.3-tree.css' ;
@import './../app/v2.3-extended-datatable-firefox.css';
@import './../app/v2.3-change-cloud-default.css';
@import './../app/v2.3-menu-default.css';
@import './../app/v2.3-user-summary-default.css';
@import './../app/v2.3-user-summary-firefox.css';
@import './../app/v2.3-recent-task-firefox.css';

JS:

document.write("<script type='text/javascript' src='../script/jhashtable.js'></script>");
document.write("<script type='text/javascript' src='../script/action-menu/jquery-top-menu.js'></script>");
document.write("<script type='text/javascript' src='../script/jquery.treeview.js'></script>");
document.write("<script type='text/javascript' src='../script/action-menu/top-menu-impl.js'></script>");
document.write("<script type='text/javascript' src='../script/popup-modal-dialog.js'></script>");
document.write("<script type='text/javascript' src='../script/navigationSideBar.js'></script>");
document.write("<script type='text/javascript' src='../script/action-menu/action-menu-script.js'></script>");
document.write("<script type='text/javascript' src='../script/appUiComponents.js'></script>");
document.write("<script type='text/javascript' src='../script/app-ui-validator.js'></script>");

It would really help if you can explain it to me, slowly, like i'm a 10 year old.

EDIT2: (found solution)
using JSF -> http://code.google.com/p/granule/
using ANT -> see below

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

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

发布评论

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

评论(2

云胡 2025-01-15 04:40:02

我不太明白你的问题。

您说过您已经使用过 apache ANT,这 100% 是我所建议的。编写一点 ANT 脚本,拥有一个很酷的静态构建过程!

http://ant.apache.org/

I don't really understand your problem.

You stated you've already used apache ANT, which is 100% what I would suggest there. Write a little ANT script, have a cool static build process !

http://ant.apache.org/

独享拥抱 2025-01-15 04:40:02
"I don't know how to use / write ANT scripts"

我想你应该靠它。或者至少是基础知识。这并不难。我按照你的链接查看了 ant 脚本。只需根据您的文件修改它即可。
替换

<concat destfile="${build.dir}/web/common/js/global.js" force="no">
       <!-- explicitly order js concat because ordering matters here -->
       <fileset dir="${build.dir}" includes="web/common/js/jquery.js" />
       <fileset dir="${build.dir}" includes="web/common/js/jquery.bgiframe.js" />
...

为您的文件

<concat destfile="${build.dir}/web/common/js/global.js" force="no">
       <!-- explicitly order js concat because ordering matters here -->
       <fileset dir="${build.dir}" includes="script/jhashtable.js" />
       <fileset dir="${build.dir}" includes="script/action-menu/jquery-top-menu.js" />
...

与 css 文件类似

"I don't know how to use / write ANT scripts"

I think you should lean it then. Or at least the basics. It is not that difficult. I followed your link and looked at the ant script. Just modify it for your files.
replace

<concat destfile="${build.dir}/web/common/js/global.js" force="no">
       <!-- explicitly order js concat because ordering matters here -->
       <fileset dir="${build.dir}" includes="web/common/js/jquery.js" />
       <fileset dir="${build.dir}" includes="web/common/js/jquery.bgiframe.js" />
...

with your files

<concat destfile="${build.dir}/web/common/js/global.js" force="no">
       <!-- explicitly order js concat because ordering matters here -->
       <fileset dir="${build.dir}" includes="script/jhashtable.js" />
       <fileset dir="${build.dir}" includes="script/action-menu/jquery-top-menu.js" />
...

Similar with css files

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