Skip to content

Commit f7d2367

Browse files
mazipanholtkamp
authored andcommitted
Gulp setup sass and autoprefixer (#358)
- Install using yarn - #355 Using SASS instead of CSS for development - #357 Setup autoprefixer in Gulpfile - Change gulp-minify-css to gulp-clean-css because deprecated - Add browsersync for hot reload development - Change link css and js in demo for hot reload
1 parent 7647d7c commit f7d2367

File tree

6 files changed

+4153
-427
lines changed

6 files changed

+4153
-427
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22
node_modules/
33
bower_components/
44
*.log
5+
package-lock.json

gulpfile.js

Lines changed: 33 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,12 @@
66
del = require('del'),
77
beautify = require("gulp-jsbeautifier"),
88
uglify = require("gulp-uglify"),
9-
minifyCSS = require("gulp-minify-css"),
9+
cleanCSS = require('gulp-clean-css'),
1010
rename = require("gulp-rename"),
11-
header = require('gulp-header');
11+
header = require('gulp-header'),
12+
sass = require('gulp-sass'),
13+
autoprefixer = require('gulp-autoprefixer'),
14+
browserSync = require('browser-sync').create();
1215

1316
var pkg = require('./package.json');
1417
var banner = ['/**',
@@ -27,11 +30,20 @@
2730

2831
gulp.task('dist:clean', function () {
2932
del.sync('./dist', {force: true});
33+
del.sync('./src/*.css', {force: true});
3034
});
3135

32-
gulp.task('dist:styles', ['dist:clean'], function () {
33-
return gulp.src('./src/*.css')
34-
.pipe(minifyCSS())
36+
gulp.task('dist:sass', ['dist:clean'], function() {
37+
return gulp
38+
.src(['./src/*.scss'])
39+
.pipe(sass({outputStyle: 'expanded'}))
40+
.pipe(autoprefixer({browsers: ['last 2 versions', 'ie 8']}))
41+
.pipe(gulp.dest('./dist'));
42+
});
43+
44+
gulp.task('dist:styles', ['dist:clean', 'dist:sass'], function () {
45+
return gulp.src('./dist/*.css')
46+
.pipe(cleanCSS({ compatibility: 'ie8' }))
3547
.pipe(rename('daterangepicker.min.css'))
3648
.pipe(gulp.dest('./dist'))
3749
.on('error', gutil.log)
@@ -46,9 +58,23 @@
4658
.on('error', gutil.log)
4759
});
4860

61+
gulp.task('dev:serve', ['dist:clean', 'dist:sass', 'dist:styles'], function() {
62+
browserSync.init({
63+
port: 3000,
64+
server: "./"
65+
});
66+
gulp.watch('./src/*.scss', ['simple-sass']);
67+
gulp.watch('./*.html').on('change', browserSync.reload);
68+
});
69+
70+
gulp.task('default', ['dist:clean', 'dist:sass', 'dist:styles', 'dist:script'], function (cb) {
71+
gutil.log('Info :', gutil.colors.green('Distribution files v.' + pkg.version + ' are ready!'));
72+
cb(null)
73+
});
4974

50-
gulp.task('default', ['dist:clean', 'dist:styles', 'dist:script'], function (cb) {
51-
gutil.log('Info :', gutil.colors.green('Distribution files are ready!'));
75+
gulp.task('dev', ['dist:clean', 'dist:sass', 'dist:styles', 'dist:script', 'dev:serve'], function (cb) {
76+
gutil.log('Info :', gutil.colors.green('Build complete!'));
77+
gutil.log('Info :', gutil.colors.green('Opening browser on http://localhost:3000/'));
5278
cb(null)
5379
});
5480

index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
66
<title>jQuery Date Range Picker Demo</title>
77
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" />
8-
<link rel="stylesheet" href="dist/daterangepicker.min.css" />
8+
<link rel="stylesheet" href="dist/daterangepicker.css" />
99
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.12.4/jquery.min.js" type="text/javascript"></script>
1010
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.16.0/moment.min.js" type="text/javascript"></script>
11-
<script src="dist/jquery.daterangepicker.min.js"></script>
11+
<script src="src/jquery.daterangepicker.js"></script>
1212
<script src="demo.js"></script>
1313
<style type="text/css">
1414
#wrapper

package.json

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
"homepage": "https://github.com/longbill/jquery-date-range-picker",
2222
"maintainers": [],
2323
"scripts": {
24+
"dist": "gulp",
25+
"dev": "gulp dev",
2426
"test": "echo \"Error: no test specified\" && exit 1"
2527
},
2628
"engines": {
@@ -34,14 +36,18 @@
3436
"jquery": ">=1.3.2"
3537
},
3638
"devDependencies": {
37-
"del": "^2.2.0",
38-
"gulp": "^3.9",
39-
"gulp-header": "^1.7",
40-
"gulp-minify-css": "^1.2",
41-
"gulp-jsbeautifier": "^2.1",
42-
"gulp-rename": "^1.2",
43-
"gulp-uglify": "^1.5",
44-
"gulp-util": "^3.0"
39+
"browser-sync": "^2.18.12",
40+
"del": "^3.0.0",
41+
"gulp": "^3.9.1",
42+
"gulp-autoprefixer": "^4.0.0",
43+
"gulp-clean-css": "^3.5.0",
44+
"gulp-header": "^1.8.8",
45+
"gulp-jsbeautifier": "^2.1.1",
46+
"gulp-rename": "^1.2.2",
47+
"gulp-sass": "^3.1.0",
48+
"gulp-uglify": "^3.0.0",
49+
"gulp-util": "^3.0.8",
50+
"gulp-watch": "^4.3.11"
4551
},
4652
"optionalDependencies": {}
4753
}

0 commit comments

Comments
 (0)