-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
93 lines (83 loc) · 2.15 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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
const autoprefixer = require('autoprefixer');
const csso = require('postcss-csso');
const gulp = require('gulp');
const clean = require('gulp-clean');
const ghPages = require('gulp-gh-pages');
const header = require('gulp-header');
const postcss = require('gulp-postcss');
const rename = require('gulp-rename');
const replace = require('gulp-replace');
const sass = require('gulp-sass');
const sync = require('browser-sync').create();
// Server
gulp.task('default', ['styles', 'js'], () => {
sync.init({
ui: false,
notify: false,
server: {
baseDir: '.'
}
});
gulp.watch('styles/**/*.scss', ['styles']);
gulp.watch('index.html').on('change', sync.reload);
});
// Styles
const ratios = ['16/10', '4/3'];
const pkg = require('./package.json');
const banner = `/**
* ${ pkg.description }
* ${ pkg.name } v${ pkg.version }, ${ pkg.homepage }
* @copyright 2010–${ new Date().getFullYear() } ${ pkg.author.name }, ${ pkg.author.url }
* @license ${ pkg.license }
*/
`;
gulp.task('styles', () => {
ratios.forEach((ratio) => {
return gulp.src('styles/screen.scss')
.pipe(replace('[RATIO]', ratio))
.pipe(sass().on('error', sass.logError))
.pipe(postcss([
autoprefixer({
browsers: [
'> 1%',
'last 2 versions',
'Firefox ESR',
'iOS >= 8',
]
}),
csso
]))
.pipe(header(banner, { pkg: pkg }))
.pipe(rename((path) => {
path.basename += `-${ ratio.replace('/', 'x') }`;
}))
.pipe(gulp.dest('styles'))
.pipe(sync.stream());
});
});
gulp.task('js', function() {
return gulp.src('./node_modules/shower-core/shower.min.js')
.pipe(gulp.dest('./'))
});
gulp.task('build:clean', function() {
return gulp.src('./dist', {read: false})
.pipe(clean());
});
gulp.task('build', ['build:clean', 'styles', 'js'], function() {
return gulp.src([
'**/*.html',
'**/*.js',
'**/*.css',
'./fonts/**',
'./pictures/**',
'./images/**',
'!node_modules',
], { base : './' })
.pipe(gulp.dest('./dist'));
})
gulp.task('deploy', ['build'], function() {
return gulp.src('./dist/**/*')
.pipe(ghPages({
remoteUrl: '[email protected]:SC5/shower-sc5.git'
}));
});