Created
March 3, 2017 15:46
-
-
Save Sankame/86e56663930ec4b8a2b0c187a7b66d61 to your computer and use it in GitHub Desktop.
bundleを1つにしたパターン
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 gulp = require('gulp'); | |
// gulpプラグイン | |
var concat = require('gulp-concat'); | |
var uglify = require('gulp-uglify'); | |
var minifyCss = require('gulp-minify-css'); | |
// タスクを定義 | |
gulp.task('js', function () { | |
gulp.src([ | |
'./path-to/js/modernizr-2.6.2.min.js' | |
,'./path-to/js/respond.min.js' | |
,'./path-to/js/jquery.min.js' | |
,'./path-to/js/jquery.easing.1.3.js' | |
,'./path-to/js/bootstrap.min.js' | |
,'./path-to/js/owl.carousel.min.js' | |
,'./path-to/js/jquery.stellar.min.js' | |
,'./path-to/js/jquery.waypoints.min.js' | |
,'./path-to/js/jquery.countTo.js' | |
,'./path-to/js/main.js' | |
]) | |
// 実行順にpipeでつなぐ | |
// ファイルを結合し、bundle.jsファイルとして出力 | |
.pipe(concat('bundle.js')) | |
// ファイルを圧縮する | |
.pipe(uglify({preserveComments: 'some'})) | |
// 最後にdistディレクトリへ出力 | |
.pipe(gulp.dest('./path-to/js/dist')); | |
}); | |
gulp.task('css', function() { | |
return gulp.src([ | |
'./path-to/css/animate.css' | |
,'./path-to/css/icomoon.css' | |
,'./path-to/css/bootstrap.css' | |
,'./path-to/css/owl.carousel.min.css' | |
,'./path-to/css/owl.theme.default.min.css' | |
,'./path-to/css/style.css' | |
]) | |
.pipe(concat('bundle.css')) | |
.pipe(minifyCss()) | |
.pipe(gulp.dest('./path-to/css/dist')); | |
}); | |
// 上記タスクをdefaultとして登録 | |
gulp.task('default', ['js','css']); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment