Last active
August 29, 2015 14:01
-
-
Save cognitom/335bfadd750fc1db38c0 to your computer and use it in GitHub Desktop.
Browserify: それはrequire()を使うための魔法の杖 ref: http://qiita.com/cognitom/items/4c63969b5085c90639d4
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Modernizr = require 'browsernizr' # npm経由 | |
$ = require 'jquery' # bower経由 | |
require './yourscript' # サイト用のスクリプト | |
# ここに書き足してもOK | |
console.log 'This page is ' + $('H1').text() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
gulp = require 'gulp' | |
browserify = require 'browserify' | |
source = require 'vinyl-source-stream' | |
gulp.task 'script', -> | |
browserify | |
entries: ['./js/src/main.coffee'] | |
extensions: ['.coffee'] # CoffeeScriptも使えるように | |
.bundle() | |
.pipe source 'main.js' # 出力ファイル名を指定 | |
.pipe gulp.dest "./js/" # 出力ディレクトリを指定 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
<略> | |
"browserify": { | |
"transform": [ | |
"coffeeify", | |
"debowerify" | |
] | |
}, | |
"devDependencies": { | |
"coffee-script": "*", | |
"vinyl-source-stream": "*", | |
"gulp": "*", | |
"bower": "*", | |
"browserify": "*", | |
"coffeeify": "*", | |
"debowerify": "*", | |
"browsernizr": "*" | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
<略> | |
"dependencies": { | |
"jquery": "*" | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ npm install && bower install |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ gulp script |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ npm install -g browserify | |
$ browserify main.js -o bundle.js |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment