This repository has been archived by the owner on Feb 9, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 18
/
gulpfile.js
73 lines (65 loc) · 2 KB
/
gulpfile.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
var autoprefixer = require( 'gulp-autoprefixer' ),
browserify = require( 'browserify' ),
buffer = require( 'vinyl-buffer' ),
gulp = require( 'gulp' ),
gutil = require( 'gulp-util' ),
notify = require( 'gulp-notify' ),
reactify = require( 'reactify' ),
sass = require('gulp-ruby-sass'),
source = require( 'vinyl-source-stream' ),
sourcemaps = require( 'gulp-sourcemaps' ),
uglify = require( 'gulp-uglify' ),
watchify = require( 'watchify' ),
watch = require( 'gulp-watch' );
gulp.task( 'react', function() {
return gulp.src( 'components/picard.jsx' )
.pipe( react() )
.pipe( gulp.dest( 'js' ) );
});
var bundler = browserify( './components/picard.jsx' );
bundler.transform( reactify );
gulp.task( 'js', bundle );
// bundler.on( 'update', bundle );
function bundle() {
return bundler.bundle()
// .on( 'error', gutil.log.bind( gutil, 'Browserify Error' ) )
.pipe( source( 'picard.js' ) )
// .pipe( buffer() )
// .pipe( sourcemaps.init( { loadMaps: true } ) )
// .pipe( sourcemaps.write( './' ) )
.pipe( gulp.dest( './' ) );
}
gulp.task('sass', function () {
return gulp.src('scss/style.scss')
.pipe( sass( {
sourcemap: true,
sourcemapPath: '../scss',
style: 'expanded'
} ) )
.on( 'error', function (err) { console.log(err.message); } )
.pipe( gulp.dest( '' ) );
});
gulp.task( 'autoprefixer', function () {
return gulp.src( 'style.css' )
.pipe(sourcemaps.init( { loadMaps: true} ) )
.pipe( autoprefixer( {
browsers: [ 'last 2 versions' ]
} ) )
.pipe( sourcemaps.write() )
.pipe(gulp.dest( '' ) );
});
// Styles
gulp.task('styles', function() {
return gulp.src('components/style.scss')
.pipe( sass() )
.pipe( autoprefixer( 'last 3 versions', 'safari 5', 'ie 8', 'ie 9', 'opera 12.1', 'ios 6', 'android 4' ) )
// .pipe( minifycss() )
.pipe( gulp.dest( './' ) )
.pipe( notify( { message: 'Styles task complete' } ) );
});
// Watcher
gulp.task( 'watch', function() {
// Watch .scss files
gulp.watch('components/**/*.scss', ['styles']);
gulp.watch('components/**/*.jsx', ['js']);
});