forked from Kinark/Materialize-stepper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
133 lines (114 loc) · 3.29 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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
var gulp = require('gulp');
var rename = require('gulp-rename');
var pump = require('pump');
var lec = require('gulp-line-ending-corrector');
var header = require('gulp-header');
var version = require('./package.json').version;
var licenseHeader = [
'/**',
' * Materialize Stepper - A little plugin that implements a stepper to Materializecss framework.',
' * @version v' + version + '',
' * @author Igor Marcossi (Kinark) <[email protected]>.',
' * @link https://github.com/Kinark/Materialize-stepper',
' * ',
' * Licensed under the MIT License (https://github.com/Kinark/Materialize-stepper/blob/master/LICENSE).',
' */',
'\n'
].join('\n');
/////////////////////
////////PATHS////////
/////////////////////
var mainScss = './src/scss/mstepper.scss';
var scssInput = './src/scss/**/*.scss';
var scssOutput = './dist/css';
var jsInput = ['./src/js/**/*.js', '!./src/js/**/_*.js'];
var jsOutput = './dist/js/';
var docsInput = './src/html_docs/**/*.html';
var docsIndex = './src/html_docs/index.html';
var docsOutput = './docs/';
/////////////////////
/////////CSS/////////
/////////////////////
var sass = require('gulp-sass');
var autoprefixer = require('gulp-autoprefixer');
var cleanCss = require('gulp-clean-css');
var sourcemaps = require('gulp-sourcemaps');
gulp.task('sass', function (cb) {
pump([
gulp.src(mainScss),
lec(),
sourcemaps.init(),
sass().on('error', onError),
autoprefixer(),
header(licenseHeader),
rename("mstepper.css"),
gulp.dest(scssOutput),
gulp.dest(docsOutput + '/css'),
sourcemaps.write(),
cleanCss(),
rename("mstepper.min.css"),
header(licenseHeader),
gulp.dest(scssOutput),
gulp.dest(docsOutput + '/css'),
], cb);
});
/////////////////////
/////////JS//////////
/////////////////////
var uglify = require('gulp-uglify');
var concatJS = require('gulp-concat');
const babel = require('gulp-babel');
gulp.task('js', function (cb) {
pump([
gulp.src(jsInput),
concatJS('mstepper.js'),
babel({
presets: ['@babel/env'],
plugins: ['@babel/plugin-proposal-class-properties']
}),
header(licenseHeader),
gulp.dest(jsOutput),
gulp.dest(docsOutput + '/js'),
uglify().on('error', onError),
rename("mstepper.min.js"),
header(licenseHeader),
gulp.dest(jsOutput),
gulp.dest(docsOutput + '/js'),
], cb);
});
/////////////////////
////////HTML/////////
/////////////////////
var fileInclude = require('gulp-file-include');
var replace = require('gulp-replace');
gulp.task('html', function (cb) {
pump([
gulp.src(docsIndex),
fileInclude({
prefix: '@@',
basepath: '@file'
}),
replace('{version}', version),
gulp.dest(docsOutput)
], cb);
});
/////////////////////
////////WATCH////////
/////////////////////
gulp.task('watchCSS', function () {
return gulp.watch(scssInput, ['sass']);
});
gulp.task('watchJS', function () {
return gulp.watch(jsInput, ['js']);
});
gulp.task('watchHTML', function () {
return gulp.watch(docsInput, ['html']);
});
/////////////////////
///////DEFAULT///////
/////////////////////
gulp.task('default', ['js', 'sass', 'html', 'watchCSS', 'watchJS', 'watchHTML']);
function onError(err) {
console.log(err);
this.emit('end');
}