Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
X
x3domlet
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
3
Issues
3
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Elphel
x3domlet
Commits
6bf45a7a
Commit
6bf45a7a
authored
Jun 15, 2017
by
Rurik Bugdanov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
gulpfile.js: convert tabs to spaces
parent
e6f808cf
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
140 additions
and
140 deletions
+140
-140
gulpfile.js
gulpfile.js
+140
-140
No files found.
gulpfile.js
View file @
6bf45a7a
...
...
@@ -3,23 +3,23 @@
var
gulp
=
require
(
'gulp'
),
bower
=
require
(
'gulp-bower'
),
wiredep
=
require
(
'wiredep'
).
stream
,
foreach
=
require
(
'gulp-foreach'
),
foreach
=
require
(
'gulp-foreach'
),
usemin
=
require
(
'gulp-usemin'
),
htmlmin
=
require
(
'gulp-htmlmin'
),
sourcemaps
=
require
(
'gulp-sourcemaps'
),
uglify
=
require
(
'gulp-uglify'
),
cleanCss
=
require
(
'gulp-clean-css'
),
rev
=
require
(
'gulp-rev'
),
htmlmin
=
require
(
'gulp-htmlmin'
),
sourcemaps
=
require
(
'gulp-sourcemaps'
),
uglify
=
require
(
'gulp-uglify'
),
cleanCss
=
require
(
'gulp-clean-css'
),
rev
=
require
(
'gulp-rev'
),
connect
=
require
(
'gulp-connect'
),
express
=
require
(
'express'
),
php
=
require
(
'node-php'
),
cors
=
require
(
'cors'
),
opn
=
require
(
'opn'
),
fs
=
require
(
'fs'
),
path
=
require
(
'path'
),
extend
=
require
(
'extend'
),
Q
=
require
(
'q'
),
clean
=
require
(
'gulp-clean'
);
path
=
require
(
'path'
),
extend
=
require
(
'extend'
),
Q
=
require
(
'q'
),
clean
=
require
(
'gulp-clean'
);
var
app
;
var
config
=
{
...
...
@@ -28,168 +28,168 @@ var config={
port
:
8080
,
home
:
'index.html'
,
bowerDir
:
'./bower_components'
,
dist
:
'./dist'
,
dist
:
'./dist'
,
}
function
abort
(
err
)
{
console
.
log
(
JSON
.
stringify
(
err
,
false
,
4
));
process
.
exit
(
1
);
console
.
log
(
JSON
.
stringify
(
err
,
false
,
4
));
process
.
exit
(
1
);
}
function
getHtmlFiles
()
{
return
gulp
.
src
(
'*.html'
);
return
gulp
.
src
(
'*.html'
);
}
// handle error events and synchronous chaining using promises
function
wrap
(
taskName
,
stream
,
q
)
{
stream
=
stream
.
on
(
'error'
,
function
errorHandler
(
err
){
console
.
log
(
'ERROR: '
+
taskName
+
' failed !'
);
console
.
log
(
JSON
.
stringify
(
err
,
false
,
4
));
if
(
q
)
{
q
.
reject
(
err
);
}
else
{
process
.
exit
(
1
);
}
}).
on
(
'end'
,
function
(){
if
(
q
)
q
.
resolve
(
stream
);
});
if
(
q
)
return
q
.
promise
;
else
return
stream
;
stream
=
stream
.
on
(
'error'
,
function
errorHandler
(
err
){
console
.
log
(
'ERROR: '
+
taskName
+
' failed !'
);
console
.
log
(
JSON
.
stringify
(
err
,
false
,
4
));
if
(
q
)
{
q
.
reject
(
err
);
}
else
{
process
.
exit
(
1
);
}
}).
on
(
'end'
,
function
(){
if
(
q
)
q
.
resolve
(
stream
);
});
if
(
q
)
return
q
.
promise
;
else
return
stream
;
}
// download bower dependencies
gulp
.
task
(
'bower'
,
function
(
cb
){
return
bower
()
return
bower
()
.
pipe
(
gulp
.
dest
(
config
.
bowerDir
));
});
// merge bower.json with file specific options
function
getBowerJson
(
srcFile
)
{
try
{
var
srcFileJson
=
require
(
srcFile
+
'.json'
);
}
catch
(
e
)
{}
var
options
=
(
srcFileJson
&&
srcFileJson
.
bower
)
||
{};
var
bowerJson
=
extend
(
true
,{},
require
(
'./bower.json'
),
options
);
return
bowerJson
;
try
{
var
srcFileJson
=
require
(
srcFile
+
'.json'
);
}
catch
(
e
)
{}
var
options
=
(
srcFileJson
&&
srcFileJson
.
bower
)
||
{};
var
bowerJson
=
extend
(
true
,{},
require
(
'./bower.json'
),
options
);
return
bowerJson
;
}
// inject bower dependencies
gulp
.
task
(
'wiredep'
,
function
(
cb
){
return
getHtmlFiles
()
.
pipe
(
foreach
(
function
(
stream
,
file
){
var
filepath
=
path
.
join
(
file
.
cwd
,
file
.
relative
);
console
.
log
(
'wiredep: '
+
filepath
);
return
stream
.
pipe
(
wrap
(
'wiredep'
,
wiredep
({
verbose
:
true
,
bowerJson
:
getBowerJson
(
filepath
)
}))
);
}))
.
pipe
(
gulp
.
dest
(
'.'
)
);
return
getHtmlFiles
()
.
pipe
(
foreach
(
function
(
stream
,
file
){
var
filepath
=
path
.
join
(
file
.
cwd
,
file
.
relative
);
console
.
log
(
'wiredep: '
+
filepath
);
return
stream
.
pipe
(
wrap
(
'wiredep'
,
wiredep
({
verbose
:
true
,
bowerJson
:
getBowerJson
(
filepath
)
}))
);
}))
.
pipe
(
gulp
.
dest
(
'.'
)
);
});
// replace references to scripts and stylesheets in html files
// and store resulting files in directory "build"
gulp
.
task
(
'usemin'
,
function
(
cb
){
return
getHtmlFiles
()
.
pipe
(
foreach
(
function
(
stream
,
file
){
console
.
log
(
'usemin: '
+
path
.
join
(
file
.
cwd
,
file
.
relative
));
return
stream
.
pipe
(
usemin
({
css
:
[
//
sourcemaps.init({
//
loadMaps: true
//
}),
wrap
(
'cleanCss'
,
cleanCss
()),
//
'concat',
rev
(),
//
sourcemaps.write()
],
html
:
[
function
()
{
return
wrap
(
'htmlmin'
,
htmlmin
({
collapseWhitespace
:
true
}));
}
],
js
:
[
sourcemaps
.
init
({
loadMaps
:
true
}),
wrap
(
'uglify js'
,
uglify
()),
'concat'
,
rev
(),
sourcemaps
.
write
()
],
inlinejs
:
[
wrap
(
'uglify inlinejs'
,
uglify
())
],
inlinecss
:
[
wrap
(
'cleanCss'
,
cleanCss
()),
'concat'
]
}));
}))
.
pipe
(
gulp
.
dest
(
'build/'
))
return
getHtmlFiles
()
.
pipe
(
foreach
(
function
(
stream
,
file
){
console
.
log
(
'usemin: '
+
path
.
join
(
file
.
cwd
,
file
.
relative
));
return
stream
.
pipe
(
usemin
({
css
:
[
//
sourcemaps.init({
//
loadMaps: true
//
}),
wrap
(
'cleanCss'
,
cleanCss
()),
//
'concat',
rev
(),
//
sourcemaps.write()
],
html
:
[
function
()
{
return
wrap
(
'htmlmin'
,
htmlmin
({
collapseWhitespace
:
true
}));
}
],
js
:
[
sourcemaps
.
init
({
loadMaps
:
true
}),
wrap
(
'uglify js'
,
uglify
()),
'concat'
,
rev
(),
sourcemaps
.
write
()
],
inlinejs
:
[
wrap
(
'uglify inlinejs'
,
uglify
())
],
inlinecss
:
[
wrap
(
'cleanCss'
,
cleanCss
()),
'concat'
]
}));
}))
.
pipe
(
gulp
.
dest
(
'build/'
))
});
gulp
.
task
(
'cleanbuild'
,
function
(){
return
gulp
.
src
(
'./build'
,
{
read
:
false
})
.
pipe
(
clean
())
return
gulp
.
src
(
'./build'
,
{
read
:
false
})
.
pipe
(
clean
())
});
// copy files to directory "dist"
gulp
.
task
(
'dist'
,
function
(
cb
)
{
var
count
=
3
;
function
goon
(){
if
(
--
count
==
0
)
{
cb
(
null
);
}
}
'dist'
,
function
(
cb
)
{
var
count
=
3
;
function
goon
(){
if
(
--
count
==
0
)
{
cb
(
null
);
}
}
// copy assets
// copy assets
wrap
(
'copy assets'
,
gulp
.
src
(
'./assets/**/*'
)
.
pipe
(
gulp
.
dest
(
config
.
dist
)),
Q
.
defer
()
)
.
catch
(
abort
)
.
then
(
goon
)
.
done
();
'copy assets'
,
gulp
.
src
(
'./assets/**/*'
)
.
pipe
(
gulp
.
dest
(
config
.
dist
)),
Q
.
defer
()
)
.
catch
(
abort
)
.
then
(
goon
)
.
done
();
// copy files
wrap
(
'copy files'
,
gulp
.
src
([
'./build/**/*'
,
'*.php'
])
.
pipe
(
gulp
.
dest
(
config
.
dist
)),
Q
.
defer
()
)
.
catch
(
abort
)
.
then
(
goon
)
.
done
();
// copy files
wrap
(
'copy files'
,
gulp
.
src
([
'./build/**/*'
,
'*.php'
])
.
pipe
(
gulp
.
dest
(
config
.
dist
)),
Q
.
defer
()
)
.
catch
(
abort
)
.
then
(
goon
)
.
done
();
// copy images
wrap
(
'copy images'
,
gulp
.
src
([
'./js/**/*.png'
]).
pipe
(
gulp
.
dest
(
path
.
join
(
config
.
dist
,
'js'
))),
Q
.
defer
()
)
.
catch
(
abort
)
.
then
(
goon
)
.
done
();
}
wrap
(
'copy images'
,
gulp
.
src
([
'./js/**/*.png'
]).
pipe
(
gulp
.
dest
(
path
.
join
(
config
.
dist
,
'js'
))),
Q
.
defer
()
)
.
catch
(
abort
)
.
then
(
goon
)
.
done
();
}
);
// serve content through express and php-cgi
function
php_cgi
(
connect
,
options
)
{
...
...
@@ -211,7 +211,7 @@ gulp.task('server',function(cb){
},
livereload
:
true
});
cb
(
null
);
cb
(
null
);
});
// watch for changes
...
...
@@ -226,8 +226,8 @@ gulp.task('watch', function(cb){
'**.js'
,
'**.kml'
,
'**.x3d'
,
'!build/**/*'
,
'!gulpfile.js'
'!build/**/*'
,
'!gulpfile.js'
],
gulp
.
series
(
'html'
)
);
...
...
@@ -235,14 +235,14 @@ gulp.task('watch', function(cb){
// trigger package injection/removal on bower.json change
gulp
.
watch
(
'bower.json'
,
gulp
.
series
(
'inject'
));
cb
(
null
);
cb
(
null
);
});
// open browser
gulp
.
task
(
'open'
,
function
(
cb
){
opn
(
'http://'
+
config
.
host
+
':'
+
config
.
port
+
'/'
+
config
.
home
);
cb
(
null
);
cb
(
null
);
});
gulp
.
task
(
'connect'
,
gulp
.
series
(
'server'
,
'watch'
,
'open'
));
...
...
@@ -260,8 +260,8 @@ gulp.task('inject', gulp.series('bower','wiredep'));
gulp
.
task
(
'build'
,
gulp
.
series
(
'bower'
,
'wiredep'
,
'usemin'
));
gulp
.
task
(
'prod-root'
,
function
(
cb
){
config
.
documentRoot
=
config
.
dist
;
cb
(
null
);
config
.
documentRoot
=
config
.
dist
;
cb
(
null
);
});
// start server with frorm "build" directory
...
...
@@ -269,5 +269,5 @@ gulp.task('prod', gulp.series('prod-root','build','dist','connect'));
gulp
.
task
(
'default'
,
gulp
.
series
(
'inject'
,
'connect'
)
gulp
.
series
(
'inject'
,
'connect'
)
);
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment