Created
December 18, 2017 10:29
-
-
Save alonstar/1904748bd92263082f13cd32301a7283 to your computer and use it in GitHub Desktop.
Gulp Config for Sass & 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
// gulpfile.js | |
var gulp = require('gulp'), | |
concat = require('gulp-concat'), | |
uglify = require('gulp-uglify'), | |
cssmin = require("gulp-cssmin"), | |
sass = require("gulp-sass"), | |
rename = require("gulp-rename"); | |
var paths = { | |
webroot: "./wwwroot/" | |
}; | |
paths.concatJsDest = paths.webroot + "js"; | |
paths.concatCssDest = paths.webroot + "styles/css"; | |
paths.scss = "./Styles/**/*.scss"; | |
gulp.task('vender-css', function () { | |
return gulp.src(['./node_modules/bootstrap/dist/css/bootstrap.min.css', './node_modules/font-awesome/css/font-awesome.min.css']) | |
.pipe(concat('vender.min.css')) | |
.pipe(gulp.dest(paths.concatCssDest)); | |
}); | |
gulp.task('vender-js', function () { | |
return gulp.src(['./node_modules/jquery/dist/jquery.min.js', | |
'./node_modules/jquery-validation/dist/jquery.validate.min.js', | |
'./Venders/jquery-validation-unobtrusive/jquery.validate.unobtrusive.min.js', // npm 上的版本沒有min檔,所以先手動下載放到venders | |
'./node_modules/popper.js/dist/umd/popper.min.js', | |
'./node_modules/bootstrap/dist/js/bootstrap.min.js']) | |
.pipe(concat('vender.min.js')) | |
.pipe(gulp.dest(paths.concatJsDest)); | |
}); | |
gulp.task('sass', function () { | |
return gulp.src(paths.scss) | |
.pipe(sass().on('error', sass.logError)) | |
.pipe(gulp.dest(paths.concatCssDest)) | |
.pipe(cssmin()) | |
.pipe(rename({ suffix: '.min' })) | |
.pipe(gulp.dest(paths.concatCssDest)); | |
}); | |
gulp.task('sass:watch', function () { | |
gulp.watch(paths.scss, ['sass']); | |
}); | |
gulp.task('build', ['vender-js', 'vender-css', 'sass']); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment