1.5.11 • Published 9 years ago

generator-giraffe v1.5.11

Weekly downloads
6
License
-
Repository
github
Last release
9 years ago

generator-giraffe

npm.io

A generator for Yeoman.
高速化を念頭に置いて作成した静的サイト構築用ジェネレータです。

About giraffe

機能

  • ディレクトリの初期構築
  • CoffeeScriptのコンパイル
  • TypeScriptのコンパイル
  • Sassのコンパイル
  • css/jsファイルの結合&圧縮
  • jsHintによるチェック
  • cssLintによるチェック
  • cssの重複プロパティチェック
  • cssの不要プレフィックス削除
  • este-watchによるファイル更新の監視→コンパイル・結合・圧縮・デバッグの自動化
  • 自動ブラウザリロード
  • jQueryの取得(バージョン指定可)
  • mixinライブラリ(bourbon)を搭載
  • 最新normalize/modernizr/font-awesomeの取得
  • spritesmithによるsprite作成
  • grunt-kssによるスタイルガイド生成
  • 各種mixinなどのscssライブラリを追加
  • Jadeに対応

Install

使用する前に以下のツール群をインストールする必要があります。
一部古いNode.jsに対応していないものもあるため、 バージョンが古い場合は、できるだけアップデートしておくことを推奨します。
Windows環境ではRubyのインストール、MacとWindow両方ともSass/Compassのインストールが前提になります。

$ npm install -g yo grunt-cli bower livereloadx
$ gem install csscss

How to use

generator-giraffeをインストールします。

npm install -g generator-giraffe

任意のディレクトリを作成して移動し、yo giraffe & grunt startを実行します。
環境によっては実行前にgit config --global url."https://".insteadOf git://を実行する必要があります。

mkdir hogehoge
cd hogehoge
yo giraffe && grunt start

yeomanからの質問形式で以下の設定を行います。

  • 開発者名(packageのauthorに入ります)
  • localhost(プロジェクト名)
  • ルートディレクトリ名
  • OS選択(YesでMac,NoでWin)
  • TypeScriptを使用するかどうか
  • CoffeeScriptを使用するかどうか
  • Jadeを使用するかどうか
  • FontAwesomeを使用するかどうか
  • jQueryのバージョン(無記入で最新版)
  • 共通リソースディレクトリ名
  • コンパイル言語ファイルの格納先
  • 開発ツールディレクトリ名
  • ドキュメントディレクトリ名

質問に返答後、返答内容に応じたディレクトリが構成され、
node_module等が自動的にインストールされます。

####js,cssファイルの結合

Gruntfile.jsを開き、結合したいcss,jsのパスを通します。
上から順に結合されていくので、順番を間違えないようにしてください。
ちなみにGrunt.jsにおいてルート相対・絶対パスは認識されません。

concat: {
	style: {
		src: [
			'<%= path.root %>/<%= path.src %>/css/normalize.css',
			'<%= path.root %>/<%= path.src %>/css/hogehoge.css'
		],
		dest: '<%= path.root %>/<%= path.src %>/css/dest/style-all.css'
	},
	run: {
		src: [
			'<%= path.root %>/<%= path.src %>/js/modernizr.js',
			'<%= path.root %>/<%= path.src %>/js/jquery.min.js',
			'<%= path.root %>/<%= path.src %>/js/hogehoge.js'
		],
		dest: '<%= path.root %>/<%= path.src %>/js/dest/run-all.js
	}
},

ファイル監視の起動

cmd_batまたはcmd_commandフォルダの中にあるgrunt_watch.batまたはgrunt_watch.commandを叩いてください。
Grunt.jsで設定したlocalhost名でページが開き、ファイルの監視が始まります。 Sublime Text2でlivereloadのプラグインを入れてる人は、バッティングするのでプラグインをremoveしてから使ってください。
この後、コンソールは出したままにしておいてください。最小化しても大丈夫です。
以降はscss/coffee/js(Sassのみの時)が更新される度に自動的にコンパイル・結合・圧縮・デバッグが行われます。
さらに、htmlとcss(sassを使っている人はscss更新時)の更新時に自動でブラウザがリロードされます。
コンソールは消さずに出したままにしておいてください。監視をやめたい場合はコンソール上でCtrl+Cを押してください。   任意のタイミングでコンパイル・結合・圧縮・デバッグを行いたい場合はgrunt_command.batまたはgrunt_command.commandを叩くか、コンソール上で「grunt」と打ち込んでください。

livereloadのアドオン・エクステンションを取得

Firefox
http://feedback.livereload.com/knowledgebase/articles/86242-how-do-i-install-and-use-the-browser-extensions-
「Firefox extension」というやつです。

Chrome
https://chrome.google.com/webstore/detail/livereload/jnihajbhpnppcggbcgedagnkighmdlei

あとは追加されたアドオンのマークを押して、丸の中が赤くなれば成功です。
ファイル監視を行っている最中に行ってください。
後はhtmlまたはcss(sassの人はscss)を編集して保存した際にブラウザがリロードされればok。

styleguideの作成

cmd_batまたはcmd_commandフォルダの中にあるgrunt_style-guideを叩くとstyleguideの作成が始まります。初期設定ではtemplate格納先はstyleguide_tempフォルダに、出力先はmodulesフォルダ内に設定されています。

重複プロパティのチェックとcss・jsのlint/hintチェック

cmd_batまたはcmd_commandフォルダの中にあるgrunt_checkを叩くと重複プロパティのチェックとcss/jsのlint/hintが始まります。初期設定では/common/css/destと/common/js/dest内にチェックの指定先が設定されています。lintの設定等はGruntfile.jsを書き換えて設定可能です。

不要プレフィックスのチェック

不要なプレフィックスを削除するためにautoprefixerを使用しています。ブラウザのバージョン指定はGruntfile.jsの下記部分になります。こちらのバージョンは変更可能です。下記リンクを参考にしてください。

/* cssファイルの不要prefix消去
 ------------------------------------------------------------------------*/
autoprefixer: {
	options: {
		// ブラウザのバージョン指定
		browsers: ['last 2 version', 'ie 8']
	},
	no_dest: {
		src: '<%= path.root %>/<%= path.src %>/css/dest/*.css'
	}
},

スプライトシートの作成

Compassで毎回書き出すと遅くなるので、Compassのスプライトシート生成はgrunt-spritesmithで代用しています。cmd_batまたはcmd_commandフォルダの中にあるgrunt_spriteを叩くとスプライトシートの生成が始まります。初期設定では/common/img/sprite内のpng画像が結合され、/common/img/にsprite.pngとして書き出されます。また、スタイルの設定ファイルは/common/compile/scss/lib/_sprite.scssに上書きされます。

License

MIT License

1.5.11

9 years ago

1.5.10

9 years ago

1.5.8

9 years ago

1.5.7

9 years ago

1.5.6

10 years ago

1.5.5

10 years ago

1.5.4

10 years ago

1.5.3

10 years ago

1.5.2

10 years ago

1.5.1

10 years ago

1.5.0

10 years ago

1.4.24

10 years ago

1.4.23

10 years ago

1.4.22

10 years ago

1.4.21

10 years ago

1.4.20

10 years ago

1.4.19

10 years ago

1.4.18

10 years ago

1.4.17

10 years ago

1.4.15

10 years ago

1.4.14

10 years ago

1.4.13

10 years ago

1.4.12

10 years ago

1.4.11

10 years ago

1.4.10

10 years ago

1.4.9

10 years ago

1.4.8

10 years ago

1.4.7

10 years ago

1.4.6

10 years ago

1.4.5

10 years ago

1.4.4

10 years ago

1.4.3

10 years ago

1.4.2

10 years ago

1.4.1

10 years ago

1.4.0

10 years ago

1.3.38

10 years ago

1.3.37

10 years ago

1.3.36

10 years ago

1.3.35

10 years ago

1.3.34

10 years ago

1.3.33

10 years ago

1.3.32

10 years ago

1.3.31

10 years ago

1.3.29

10 years ago

1.3.27

10 years ago

1.3.26

10 years ago

1.3.25

10 years ago

1.3.24

10 years ago

1.3.23

10 years ago

1.3.22

10 years ago

1.3.21

10 years ago

1.3.20

10 years ago

1.3.19

10 years ago

1.3.18

10 years ago

1.3.16

10 years ago

1.3.15

10 years ago

1.3.14

10 years ago

1.3.13

10 years ago

1.3.12

10 years ago

1.3.11

10 years ago

1.3.10

10 years ago

1.3.9

10 years ago

1.3.8

10 years ago

1.3.7

10 years ago

1.3.6

10 years ago

1.3.5

10 years ago

1.3.4

10 years ago

1.3.3

10 years ago

1.3.2

10 years ago

1.3.1

10 years ago

1.3.0

10 years ago

1.2.21

10 years ago

1.2.20

10 years ago

1.2.19

10 years ago

1.2.18

10 years ago

1.2.17

10 years ago

1.2.16

10 years ago

1.2.15

10 years ago

1.2.14

10 years ago

1.2.13

10 years ago

1.2.12

10 years ago

1.2.11

10 years ago

1.2.10

10 years ago

1.2.9

10 years ago

1.2.8

10 years ago

1.2.7

10 years ago

1.2.6

10 years ago

1.2.5

10 years ago

1.2.4

10 years ago

1.2.3

10 years ago

1.2.2

10 years ago

1.2.1

10 years ago

1.2.0

10 years ago

1.1.21

10 years ago

1.1.20

10 years ago

1.1.19

10 years ago

1.1.18

10 years ago

1.1.17

10 years ago

1.1.16

10 years ago

1.1.15

10 years ago

1.1.14

10 years ago

1.1.13

10 years ago

1.1.12

10 years ago

1.1.11

10 years ago

1.1.10

10 years ago

1.1.9

10 years ago

1.1.8

10 years ago

1.1.7

10 years ago

1.1.6

10 years ago

1.1.5

10 years ago

1.1.4

10 years ago

1.1.3

10 years ago

1.1.2

10 years ago

1.1.1

10 years ago

1.1.0

10 years ago

1.0.29

10 years ago

1.0.28

10 years ago

1.0.27

10 years ago

1.0.26

10 years ago

1.0.25

10 years ago

1.0.24

10 years ago

1.0.23

10 years ago

1.0.22

10 years ago

1.0.20

10 years ago

1.0.19

10 years ago

1.0.18

10 years ago

1.0.17

10 years ago

1.0.16

10 years ago

1.0.15

10 years ago

1.0.14

10 years ago

1.0.13

10 years ago

1.0.12

10 years ago

1.0.11

10 years ago

1.0.10

10 years ago

1.0.9

10 years ago

1.0.8

10 years ago

1.0.6

10 years ago

1.0.5

10 years ago

1.0.4

10 years ago

1.0.3

10 years ago

1.0.2

10 years ago

1.0.1

11 years ago

1.0.0

11 years ago