Last active
January 28, 2017 17:54
-
-
Save th3mon/a81ebefcdf8cbac0467f1200eaff0c4a to your computer and use it in GitHub Desktop.
aurelia dist task
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import gulp from 'gulp'; | |
import project from '../aurelia.json'; | |
import build from './build'; | |
import del from 'del'; | |
function dist() { | |
let defaults = { | |
index: 'index.html', | |
dist: { | |
root: 'dist', | |
source: [ | |
'scripts', | |
'img', | |
'locales', | |
'fonts' | |
] | |
} | |
}; | |
return gulp.src([ | |
getIndex(defaults), | |
...getSource(defaults) | |
], { | |
base: '.' | |
}).pipe(gulp.dest(getRoot(defaults))); | |
} | |
function getIndex(defaults) { | |
let index = (project.platform && | |
project.platform.index) || | |
defaults.index; | |
return index; | |
} | |
function getSource(defaults) { | |
let sources = (project.paths && | |
project.paths.dist && | |
project.paths.dist.source) || | |
defaults.dist.source; | |
return sources.map((source) => `${source}/**/*`); | |
} | |
function getRoot(defaults) { | |
let root = (project.paths && | |
project.paths.dist && | |
project.paths.dist.root) || | |
defaults.dist.root; | |
return root; | |
} | |
function cleanDist() { | |
return del('dist'); | |
} | |
export default gulp.series( | |
build, | |
cleanDist, | |
dist | |
); | |
// Usage | |
// au dist --env prod | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment