整合ajaxmin 和 less 到VS.net

??? 我用的前端框架是bootstrap_extra, twitter團隊做的,這個是他的一個擴展,首先從上面下載一個。至于ajaxmin,請參考這里

? ??

?? 1) 從bootstrap_extra的解壓包中,復制build目錄下三個文件到項目中去,這三個文件分別是

  • ?? BatchSubsitute.bat ?
  • ?? less.js
  • ?? lessc. wsf

? 2) 然后加入到Vs.net 的項目中,我把build目錄排除出項目外,這樣使用publish功能的時候,就不會把Build目錄頁發布出去。

?

?3) 編寫less.bat,其中我的 less文件是放在 項目目錄下面 Content\less\ ?

call?BatchSubstitute.bat?"@VERSION"?"1.4.0"?..\Content\less\bootstrap_xtra.less?>?..\Content\less\bootstrap_xtra.tmp.less
call?BatchSubstitute.bat?"@DATE"?"%date%?%time%"?..\Content\less\bootstrap_xtra.tmp.less?>?..\Content\less\bootstrap_xtra.tmp.1.less
cd?../Content/less
@cscript?//nologo?"http://www.cnblogs.com/build/lessc.wsf"?bootstrap_xtra.tmp.1.less?../combine/bootstrap.css

del?/f?bootstrap_xtra.tmp.less
del?/f?bootstrap_xtra.tmp.1.less

cd?http://www.cnblogs.com/build

?

3) 然后用記事本,或者notepad++之類的編輯器修改 項目文件,如 hehe.csproj

找到編譯Web項目的Task,一般如下:

?

<Target Name="MvcBuildViews" AfterTargets="AfterBuild" Condition="'$(MvcBuildViews)'=='true'">
??? <AspNetCompiler VirtualPath="temp" PhysicalPath="$(ProjectDir)\..\$(ProjectName)" />
?</Target>

?

?紅色部分是 編譯成功之后,執行的Task名稱叫做“AfterBuild",然后啟動我們剛剛寫得less.bat,執行編譯css,留意一下WorkingDirectory,我是假設執行目錄是在build目錄執行的,否知會出錯。

?

<Target Name="AfterBuild">
??? <Exec Command="$(MSBuildProjectDirectory)\Build\less.bat" ContinueOnError="false" WorkingDirectory="$(MSBuildProjectDirectory)\Build\" />
??? <ItemGroup>
????? <JS Include="**\Scripts\Combine\*.js" Exclude="**\Scripts\Combine\*.min.js" />
??? </ItemGroup>
??? <ItemGroup>
????? <CSS Include="**\Content\Combine\*.css" Exclude="**\Content\Combine\*.min.css" />
??? </ItemGroup>
??? <AjaxCombine JsSourceFiles="@(JS)" JsCombinedFileName="..\global.js" CssSourceFiles="@(CSS)" CssCombinedFileName="..\global.css" />
??? <ItemGroup>
????? <COMBINEDJS Include="**\Scripts\global.js" Exclude="**\Scripts\*.min.js" />
??? </ItemGroup>
??? <ItemGroup>
????? <COMBINEDCSS Include="**\Content\global.css" Exclude="**\Content\*.min.css" />
??? </ItemGroup>
??? <AjaxMin JsSourceFiles="@(COMBINEDJS)" JsSourceExtensionPattern="\.js$" JsTargetExtension=".min.js" CssSourceFiles="@(COMBINEDCSS)" CssSourceExtensionPattern="\.css$" CssTargetExtension=".min.css" />
? </Target>
? <Target Name="MvcBuildViews" AfterTargets="AfterBuild" Condition="'$(MvcBuildViews)'=='true'">
??? <AspNetCompiler VirtualPath="temp" PhysicalPath="$(ProjectDir)\..\$(ProjectName)" />
? </Target>



less編譯完畢之后,我們就執行 用ajaxmin,執行壓縮,這個配置請參考這里

?

以下是新增的部分

?

?

<Import Project="$(MSBuildProjectDirectory)\Build\ajaxmin.tasks" />
? <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
?????? Other similar extension points exist, see Microsoft.Common.targets.
? <Target Name="BeforeBuild">
? </Target> -->
?
? <Target Name="AfterBuild">
??? <Exec Command="$(MSBuildProjectDirectory)\Build\less.bat" ContinueOnError="false" WorkingDirectory="$(MSBuildProjectDirectory)\Build\" />
??? <ItemGroup>
????? <JS Include="**\Scripts\Combine\*.js" Exclude="**\Scripts\Combine\*.min.js" />
??? </ItemGroup>
??? <ItemGroup>
????? <CSS Include="**\Content\Combine\*.css" Exclude="**\Content\Combine\*.min.css" />
??? </ItemGroup>
??? <AjaxCombine JsSourceFiles="@(JS)" JsCombinedFileName="..\global.js" CssSourceFiles="@(CSS)" CssCombinedFileName="..\global.css" />
??? <ItemGroup>
????? <COMBINEDJS Include="**\Scripts\global.js" Exclude="**\Scripts\*.min.js" />
??? </ItemGroup>
??? <ItemGroup>
????? <COMBINEDCSS Include="**\Content\global.css" Exclude="**\Content\*.min.css" />
??? </ItemGroup>
??? <AjaxMin JsSourceFiles="@(COMBINEDJS)" JsSourceExtensionPattern="\.js$" JsTargetExtension=".min.js" CssSourceFiles="@(COMBINEDCSS)" CssSourceExtensionPattern="\.css$" CssTargetExtension=".min.css" />
? </Target>
? <Target Name="MvcBuildViews" AfterTargets="AfterBuild" Condition="'$(MvcBuildViews)'=='true'">
??? <AspNetCompiler VirtualPath="temp" PhysicalPath="$(ProjectDir)\..\$(ProjectName)" />
? </Target>

?

?

如果是使用 bootstrap 2.0.1,從sourcecode給的Less,在上面的腳本Less.js(已經是最新的)運行時會出錯的,請教一下誰有更好的解決方案請告知我。

我的修復方式如下:

把下面這一段,移動到 @import "reset.less" 之前,因為Reset.less 引用了 minxs.less的 東西。

// Core variables and mixins
@import "variables.less"; // Modify this for custom colors, font-sizes, etc
@import "mixins.less";

?

打開 variable.less


// Sprite icons path
@iconSpritePath:????????? “../img/glyphicons-halflings.png";
@iconWhiteSpritePath:? "../img/glyphicons-halflings-white.png";

?修改為 帶 url的變量,例如向下面那種:

// Sprite icons path

@iconSpritePath:????????? url('img/glyphicons-halflings.png');
@iconWhiteSpritePath:???? url('img/glyphicons-halflings-white.png');

轉到sprite.less,把引用上面變量的地方,改為像下面那種樣式


? ? backgroupd-image: url(@iconSpritePath)?

改為

backgroupd-image: @iconSpritePath

?


?


?


?

? ?

轉載于:https://www.cnblogs.com/fantasylu/archive/2012/03/01/2376034.html

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/377693.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/377693.shtml
英文地址,請注明出處:http://en.pswp.cn/news/377693.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

轉:只能選擇GridView中的一個CheckBox(單選CheckBox)

方法1&#xff1a; protected void GridView2_RowDataBound(object sender, GridViewRowEventArgs e){CheckBox cbx e.Row.FindControl("cbID") as CheckBox;try{//綁定選中CheckBox 客戶端IDcbx.Attributes.Add("onclick", "Change(" cbx.Cli…

六、出庫管理功能的實現

一、數據庫的建立 這里仍使用yy_textile表 在fiber_yy數據庫下創建yy_textile表 初始數據庫信息 二、頁面的完善 登錄注冊頁面我就不演示了&#xff0c;前幾篇博文也都有介紹 shipment出庫管理頁面 main_page頁面進行功能完善 三、代碼實現 shipment出庫管理頁面 u…

數學建模:層次分析法實例以及代碼

博主聯系方式&#xff1a; QQ:1540984562 QQ交流群&#xff1a;892023501 群里會有往屆的smarters和電賽選手&#xff0c;群里也會不時分享一些有用的資料&#xff0c;有問題可以在群里多問問。 目錄層次分析法的思想層次分析法步驟具體案例(市政工程項目建設決策)1.問題提出2.…

c 僵尸進程_演示僵尸進程的C程序

c 僵尸進程僵尸進程 (Zombie process) A process which has finished its execution but still has an entry in the process table to report to its parent process is known as a zombie process. 一個已經完成執行但仍在進程表中具有要報告給其父進程的條目的進程稱為僵尸進…

探秘IntelliJ IDEA 13測試版新功能——調試器顯示本地變量

IntelliJ IDEA在業界被公認為最好的Java開發平臺之一&#xff0c;JetBrains公司將在12月正式發布IntelliJ IDEA 13版本。 現在&#xff0c;小編將和大家一起探秘密IntelliJ IDEA 13測試版本新功能——調試器顯示本地變量。這個功能非常強大&#xff0c;調試器可以顯示變量&…

C# Windows Form下的控件的Validator(數據驗證)

由于偶爾的一個想法&#xff0c;謀生了一個做一個windows form下的Validator控件&#xff0c;或者直接說類吧&#xff01; 因為webform下的Validator控件太好用了。哈哈&#xff0c;直接看代碼&#xff01; 下面這個類&#xff0c;主要是一個簡單的驗證類&#xff0c;不過只是起…

七、流水查詢---記錄用戶登錄信息

一、數據庫的建立 在fiber_yy數據庫下創建yy_user_record表 可以先手動填入幾條數據信息 初始數據庫信息 username為用戶賬號 sex為用戶注冊所填寫的性別 phone為用戶手機號 time為用戶登錄該系統的時間 二、頁面的設計 登錄注冊頁面我就不演示了&#xff0c;前幾篇博文…

leetcode 455. 分發餅干 思考分析

目錄題目自己的思路以及AC代碼參考思路題目 假設你是一位很棒的家長&#xff0c;想要給你的孩子們一些小餅干。但是&#xff0c;每個孩子最多只能給一塊餅干。 對每個孩子 i&#xff0c;都有一個胃口值 g[i]&#xff0c;這是能讓孩子們滿足胃口的餅干的最小尺寸&#xff1b;并…

c++ cdi+示例_C ++'not'關鍵字和示例

c cdi示例"not" is an inbuilt keyword that has been around since at least C98. It is an alternative to ! (Logical NOT) operator and it mostly uses with the conditions. “ not”是一個內置關鍵字&#xff0c;至少從C 98起就存在。 它是替代&#xff01; …

【second】Flatten Binary Tree to Linked List

遞歸 void flatten(TreeNode *root) {// Note: The Solution object is instantiated only once and is reused by each test case.flat(root);}TreeNode* flat(TreeNode* root){if(!root)return NULL;TreeNode* left_tail flat(root->left);TreeNode* right_tail flat(ro…

八、流水查詢---記錄紡織品出庫信息

一、數據庫的建立 在fiber_yy數據庫下創建yy_textile_record表 可以先手動填入幾條數據信息 初始數據庫信息 第一條數據的username是空格不是null number為織物的品號(唯一的) stock為出貨量 username為哪個賬號 time為出貨時間 二、頁面的完善 登錄注冊頁面我就不演示…

應用程序欄【WP7學習札記之九】

本節是WP7學習札記的第九篇&#xff0c;講的是系統托盤和應用程序欄&#xff0c;具體內容是系統托盤和應用程序欄的介紹&#xff0c;如何分別使用C#、xaml以及Expression Blend生成應用程序欄&#xff0c;應用程序欄的透明度以及對屏幕方向改變的支持。摘要如下&#xff1a; 系…

橢圓曲線密碼學導論pdf_橢圓曲線密碼學

橢圓曲線密碼學導論pdf歷史 (History) The use of elliptic curves in cryptography was advised independently by Neal Koblitz and Victor S. Miller in 1985. Elliptic curve cryptography algorithms entered large use from 2004 to 2005. 1985年&#xff0c; Neal Kobli…

leetcode 第 216 場周賽 整理

目錄1662. 檢查兩個字符串數組是否相等題目自己代碼5606. 具有給定數值的最小字符串題目自己代碼貪心算法1664. 生成平衡數組的方案數題目自己代碼動態規劃優化1665. 完成所有任務的最少初始能量題目思路1662. 檢查兩個字符串數組是否相等 題目 給你兩個字符串數組 word1 和 …

九、忘記密碼功能的實現

一、頁面設計 login頁面&#xff0c;和第二篇博文(用戶登錄和注冊)頁面基本一樣&#xff0c;只不過多了一個按鈕 其中忘記密碼&#xff1f;點我找回 為button3 retrieve_password頁面 change_password頁面 頁面如下&#xff1a; 二、數據庫 因為是忘記密碼&#xff0c;…

Android中對手機文件進行讀寫

參考張澤華視頻 &#xff08;一&#xff09;讀寫手機內存卡中的文件 對手機中的文件進行讀寫操作&#xff0c;或者新增一個文件時&#xff0c;可直接使用openFileOutput / openFileInput 得到文件的輸出、輸入流。 FileOutputStream fos this.openFileOutput("private.…

聯軸器選型_聯軸器| 軟件工程

聯軸器選型耦合 (Coupling) In general terms, the term coupling is defined as a thing that joins together two objects. If we talk about software development, then the term coupling is related to the connection between two modules, i.e. how tight interaction …

劍指 Offer 10- I. 斐波那契數列 (從重疊子問題到備忘錄到dp數組迭代解法)

目錄題目描述1、暴力遞歸法的重疊子問題2、備忘錄解法3、dp數組迭代算法4、滾動數組優化5、參考鏈接題目描述 寫一個函數&#xff0c;輸入 n &#xff0c;求斐波那契&#xff08;Fibonacci&#xff09;數列的第 n 項。斐波那契數列的定義如下&#xff1a; F(0) 0, F(1) 1 F…

C# 收郵件

C#沒有內置收郵件的類&#xff0c;參考網絡上的代碼&#xff0c;針對POP3協議服務器使用 Jmail組件來收郵件&#xff0c;針對IMAP協議服務器使用LumiSoft.Net 。 另外&#xff0c;一般免費郵箱需要在郵箱設置中開啟 POP3&#xff08;或IMAP&#xff09;、 SMTP服務才可以使用非…

HDU- 1754 I Hate It

http://acm.hdu.edu.cn/showproblem.php?pid1754 記住那讓自己wa的地方。 I Hate It Time Limit: 9000/3000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 29300 Accepted Submission(s): 11615 Problem Description很多學校流行…