forked from OriginalEXE/vidim
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
159 lines (123 loc) · 2.82 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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
const gulp = require( 'gulp' );
const sass = require( 'gulp-sass' );
const autoprefixer = require( 'gulp-autoprefixer' );
const del = require( 'del' );
const rollup = require( 'rollup' ).rollup;
const babel = require( 'rollup-plugin-babel' )
const commonjs = require( 'rollup-plugin-commonjs' );
const nodeResolve = require( 'rollup-plugin-node-resolve' );
const eslint = require( 'rollup-plugin-eslint' );
const uglify = require( 'rollup-plugin-uglify' );
const package = require( './package.json' );
function dev() {
return rollup({
entry: 'src/index.js',
plugins: [
eslint(),
nodeResolve({ jsnext: true }),
commonjs(),
babel({
exclude: 'node_modules/**'
})
]
}).then( function( bundle ) {
return bundle.write({
dest: 'dist/vidim.js',
format: 'umd',
moduleName: 'vidim',
sourceMap: true
});
});
};
function devWatch() {
dev();
gulp.watch( 'src/**/*.js', dev );
};
function cleanDistFolder() {
return del([
'dist/**/*'
]);
}
function build() {
cleanDistFolder();
var date = new Date;
var banner =
'/* \n' +
' * vidim v' + package.version + '\n' +
' * ' + date.toISOString() + '\n' +
' * https://github.com/OriginalEXE/vidim \n' +
' * \n' +
' * Made by Ante Sepic \n' +
' */';
return rollup({
entry: 'src/index.js',
plugins: [
eslint(),
nodeResolve({ jsnext: true }),
commonjs(),
babel({
exclude: 'node_modules/**'
}),
uglify({
output: {
comments: function( node, comment ) {
if ( 'comment2' === comment.type ) {
return /Made by Ante Sepic/.test( comment.value );
}
}
}
})
]
}).then( function( bundle ) {
return bundle.write({
dest: 'dist/vidim.min.js',
format: 'umd',
moduleName: 'vidim',
sourceMap: false,
banner: banner
});
}).then( function() {
return rollup({
entry: 'src/index.js',
plugins: [
eslint(),
nodeResolve({ jsnext: true }),
commonjs(),
babel({
exclude: 'node_modules/**'
})
]
});
}).then( function( bundle ) {
return bundle.write({
dest: 'dist/vidim.js',
format: 'umd',
moduleName: 'vidim',
sourceMap: false,
banner: banner
});
});
}
function docs() {
docsSass();
gulp.watch( 'docs/scss/**/*.scss', docsSass );
}
function docsSass() {
return gulp.src( 'docs/scss/main.scss' )
.pipe(
sass({
outputStyle: 'compressed'
})
)
.pipe(
autoprefixer({
browsers: ['last 3 versions']
})
)
.pipe( gulp.dest( 'docs/css' ) );
}
exports.dev = dev;
exports.devWatch = devWatch;
exports.build = build;
exports.docs = docs;
exports.docsSass = docsSass;