-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
114 lines (102 loc) · 3.24 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
/**
* Gulp Tasks
*
* Created by RafahCSilva.
*/
// https://scotch.io/tutorials/automate-your-tasks-easily-with-gulp-js
// https://github.com/scotch-io/gulp-getting-started/
// https://julienrenaux.fr/2014/05/25/introduction-to-gulp-js-with-practical-examples/
const gulp = require( 'gulp' ),
minHtml = require( "gulp-minify-html" ),
minCss = require( "gulp-minify-css" ),
uglify = require( "gulp-uglify" ),
rename = require( 'gulp-rename' ),
concat = require( "gulp-concat" ),
input = {
html: 'source/index.html',
css: 'source/css/app.css',
css_vendor: [
'source/css/vendor/bootstrap.css',
'source/css/vendor/bootstrap-theme.css',
'source/css/vendor/font-awesome.css',
],
fonts: 'source/fonts/*',
svg: 'source/svg/*',
js: [
'source/javascript/utils.js',
'source/javascript/rapidabb.js',
'source/javascript/svg2abb.js',
'source/javascript/app.js',
],
js_vendor: [
'source/javascript/vendor/underscore.js',
'source/javascript/vendor/jquery-3.2.1.js',
'source/javascript/vendor/bootstrap.js',
],
},
output = {
public: 'public',
public_css: 'public/assets/stylesheets',
public_fonts: 'public/assets/fonts',
public_js: 'public/assets/javascript',
public_svg: 'public/assets/svg',
html: 'index.html',
css: 'app.css',
css_vendor: 'app_vendor.css',
js: 'app.js',
js_vendor: 'app_vendor.js',
},
name = {
html: 'minify-html',
css: 'minify-css',
css_vendor: 'minify-css_vendor',
fonts: 'copy-fonts',
svg: 'copy-svg',
js: 'minify-js',
js_vendor: 'minify-js_vendor',
default: 'default',
watch: 'watch',
};
// TASKs
gulp.task( name.html, function () {
gulp.src( input.html )
.pipe( minHtml() )
.pipe( gulp.dest( output.public ) );
} );
gulp.task( name.css_vendor, function () {
gulp.src( input.css_vendor )
.pipe( minCss() )
.pipe( concat( output.css_vendor ) )
.pipe( gulp.dest( output.public_css ) );
} );
gulp.task( name.css, function () {
gulp.src( input.css )
.pipe( minCss() )
.pipe( concat( output.css ) )
.pipe( gulp.dest( output.public_css ) );
} );
gulp.task( name.fonts, function () {
gulp.src( input.fonts )
.pipe( gulp.dest( output.public_fonts ) );
} );
gulp.task( name.svg, function () {
gulp.src( input.svg )
.pipe( gulp.dest( output.public_svg ) );
} );
gulp.task( name.js_vendor, function () {
gulp.src( input.js_vendor )
.pipe( concat( output.js_vendor ) )
//.pipe( uglify( { output: { prettify: false } } ) )
.pipe( gulp.dest( output.public_js ) );
} );
gulp.task( name.js, function () {
gulp.src( input.js )
.pipe( concat( output.js ) )
//.pipe( uglify( { compress: { unused: false } } ) )
.pipe( gulp.dest( output.public_js ) );
} );
gulp.task( name.default, [ name.html, name.css_vendor, name.css, name.fonts, name.svg, name.js_vendor, name.js ] );
gulp.task( name.watch, function () {
gulp.watch( input.html, [ name.html ] );
gulp.watch( input.js, [ name.js ] );
} );