Last active
August 29, 2015 14:27
-
-
Save nowri/0741923b772d4d5ae76a to your computer and use it in GitHub Desktop.
Revisions
-
nowri revised this gist
Aug 12, 2015 . 1 changed file with 2 additions and 6 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -3,9 +3,7 @@ var through = require('through2'); var jade = require('react-jade'); var ext = gutil.replaceExtension; module.exports = function (outputFileName) { function transform(file, enc, cb) { var jadePath = file.path; file.path = ext(file.path, '.js'); @@ -24,8 +22,6 @@ module.exports = function (outputFileName) { } cb(null, file); } return through.obj(transform); }; -
nowri revised this gist
Aug 12, 2015 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,5 +1,5 @@ { "name": "gulp-react-jade-amd", "version": "1.0.0", "description": "", "main": "index.js", -
nowri revised this gist
Aug 12, 2015 . No changes.There are no files selected for viewing
-
nowri created this gist
Aug 12, 2015 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,31 @@ var gutil = require('gulp-util'); var through = require('through2'); var jade = require('react-jade'); var ext = gutil.replaceExtension; module.exports = function (outputFileName) { /* transform関数:ファイル毎に呼び出される */ function transform(file, enc, cb) { var jadePath = file.path; file.path = ext(file.path, '.js'); if(file.isStream()){ return cb(new PluginError('gulp-jade', 'Streaming not supported')); } if(file.isBuffer()){ try { var compiled; compiled = 'define(["react"], function(React){ return ' + jade.compileFileClient(jadePath, {globalReact:true}) + '});'; file.contents = new Buffer(compiled); } catch(e) { return cb(new PluginError('gulp-jade', e)); } } cb(null, file); } /* through2オブジェクトを生成してreturn */ return through.obj(transform); }; This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,17 @@ { "name": "react-jade-amd", "version": "1.0.0", "description": "", "main": "index.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, "author": "", "license": "ISC", "devDependencies": { "gulp-util": "^3.0.6", "react": "^0.13.3", "react-jade": "^2.4.0", "through2": "^2.0.0" } }