Visual Studio 2013のビルド前イベントとして以下を使用して、この回答に従ってブートストラップ3.0をリセス付きでコンパイルしました。
recess "$(ProjectDir)Content\bootstrap\bootstrap.less" --compress > "$(ProjectDir)Content\bootstrap-compiled.css"
現在、これはBootstrap 3.1.1では機能せず、Gruntが機能すると言われています。私はもう試した:
grunt-contrib-less "$(ProjectDir)Content\bootstrap\bootstrap.less" --compress > "$(ProjectDir)Content\bootstrap-compiled.css"
しかし、それを機能させることはできません。GruntをVS2013で動作させる方法に関するアイデア。
注:以前にNode.jsをインストールして休憩した後、> npm install grunt-contrib-lessを実行してから、> npm updategrunt-contrib-lessを確認します。
私はこれを少し異なる方法で機能させています:
npm install -g grunt-cli
)call grunt less
ビルド前のイベントに追加します(CALLを指定しない場合、プロセスはうなり声の後に戻りません)必要に応じて、開発および本番ビルドプロセスにさまざまなターゲットを追加できます。他のタスク用にさらに多くのターゲットを設定することもgrunt watch
できます。編集するファイルが少ない場合にCSSを自動的に再コンパイルするために実行できるように、ターゲットを1つ持っています。
VS2013サンプルプロジェクトをより少ない使用量とGruntに変換するためのステップバイステップガイド:
ブートストラップを削除し、ブートストラップを少なくインストールします。
Uninstall-Package bootstrap
Install-Package Twitter.Bootstrap.less
grunt-cliがグローバルにインストールされていることを確認します。
npm install -g grunt-cli
package.jsonファイルを作成します。
npm init
Gruntfile.js
次の内容で呼び出されるファイルをプロジェクトに作成します。
module.exports = function (grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
less: {
dev: {
options: {
sourceMap: true,
dumpLineNumbers: 'comments',
relativeUrls: true
},
files: {
'Content/bootstrap.debug.css': 'Content/bootstrap/bootstrap.less',
}
},
production: {
options: {
cleancss: true,
compress: true,
relativeUrls: true
},
files: {
'Content/bootstrap.css': 'Content/bootstrap/bootstrap.less',
}
}
},
});
grunt.loadNpmTasks('grunt-contrib-less');
// Default task(s).
grunt.registerTask('default', ['less']);
grunt.registerTask('production', ['less:production']);
grunt.registerTask('dev', ['less:dev']);
};
Visual Studioのビルド前イベントを編集して、次のものを含めます。
cd $(ProjectDir)
call grunt --no-color
(--no-color
Visual Studioビルド出力から一部の制御文字を削除します)
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加