Last active
August 29, 2015 14:11
-
-
Save axross/e60f618b44c8dc239519 to your computer and use it in GitHub Desktop.
ライブコーディングでつかうクソgulpfile
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
var path = require('path'); | |
var gulp = require('gulp'); | |
var plumber = require('gulp-plumber'); | |
var rename = require('gulp-rename'); | |
var webpack = require('gulp-webpack'); | |
var browserSync = require('browser-sync'); | |
var modRewrite = require('connect-modrewrite'); | |
gulp.task('bundle', function() { | |
gulp.src('./public/app.jsx') | |
.pipe(plumber()) | |
.pipe(webpack({ | |
module: { | |
loaders: [ | |
{ test: /\.jsx$/, loader: 'jsx-loader?insertPragma=React.DOM&harmony' } | |
] | |
}, | |
externals: { | |
'react': 'React', | |
}, | |
resolve: { | |
extenstions: ['', '.js', '.jsx'] | |
} | |
})) | |
.pipe(rename('bundle.js')) | |
.pipe(gulp.dest('./public/dist')); | |
}); | |
gulp.task('lib', function() { | |
gulp.src('./public/lib.js') | |
.pipe(plumber()) | |
.pipe(webpack()) | |
.pipe(rename('lib.js')) | |
.pipe(gulp.dest('./public/dist')); | |
}); | |
gulp.task('build', ['bundle', 'lib']); | |
gulp.task('default', ['build']); | |
gulp.task('browser-sync', ['build'], function() { | |
gulp.watch(['./public/*.js', './public/*.jsx'], ['bundle', browserSync.reload]); | |
browserSync({ | |
server: { | |
baseDir: './public', | |
logLevel: 'debug', | |
open: true, | |
middleware: [modRewrite(['^[^\\.]*$ /index.html [L]'])], | |
}, | |
open: false | |
}); | |
}); | |
gulp.task('watch', ['browser-sync']); // alias |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment