fixed gulpfiles
This commit is contained in:
@@ -1,13 +1,3 @@
|
|||||||
/**
|
|
||||||
* @Author: Bachir Soussi Chiadmi <bach>
|
|
||||||
* @Date: 20-12-2017
|
|
||||||
* @Email: bachir@figureslibres.io
|
|
||||||
* @Filename: gulpfile.js
|
|
||||||
* @Last modified by: bach
|
|
||||||
* @Last modified time: 20-12-2017
|
|
||||||
* @License: GPL-V3
|
|
||||||
*/
|
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
import gulp from 'gulp';
|
import gulp from 'gulp';
|
||||||
@@ -67,26 +57,18 @@ function styles() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// default gulp task
|
// default gulp task
|
||||||
function defaultTask () {
|
function devwatch () {
|
||||||
series('scripts', 'styles', done => {
|
// series(scripts, styles, done => {
|
||||||
for (var i = 0; i < modules.length; i++) {
|
for (var i = 0; i < modules.length; i++) {
|
||||||
watch('./'+modules[i]+'/assets/styles/*.scss', series('styles'));
|
watch('./'+modules[i]+'/assets/styles/*.scss', styles);
|
||||||
watch('./'+modules[i]+'/assets/scripts/*.js', series('scripts'));
|
watch('./'+modules[i]+'/assets/scripts/*.js', scripts);
|
||||||
}
|
}
|
||||||
done()
|
// done()
|
||||||
})
|
// })
|
||||||
};
|
};
|
||||||
|
|
||||||
function devwatch(){
|
|
||||||
watch('./assets/styles/*.scss', series('styles'));
|
|
||||||
watch('./assets/styles/base/*.scss', series('styles'));
|
|
||||||
watch('./assets/scripts/*.js', series('scripts'));
|
|
||||||
}
|
|
||||||
|
|
||||||
export {
|
export default series(scripts, styles);
|
||||||
scripts as scripts,
|
export { devwatch }
|
||||||
styles as styles,
|
|
||||||
devwatch as devwatch,
|
|
||||||
defaultTask as default
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,10 @@
|
|||||||
"author": "Bachir Soussi Chiadmi",
|
"author": "Bachir Soussi Chiadmi",
|
||||||
"license": "GPLv3",
|
"license": "GPLv3",
|
||||||
"homepage": "https://encyclopediedelaparole.org",
|
"homepage": "https://encyclopediedelaparole.org",
|
||||||
|
"scripts": {
|
||||||
|
"dev": "gulp devwatch",
|
||||||
|
"build": "gulp --env prod"
|
||||||
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"gulp": "^5.0.0",
|
"gulp": "^5.0.0",
|
||||||
"gulp-autoprefixer": "^9.0.0",
|
"gulp-autoprefixer": "^9.0.0",
|
||||||
|
|||||||
@@ -20,13 +20,14 @@ import minimist from 'minimist';
|
|||||||
// to get minified assets run `gulp --env=prod`
|
// to get minified assets run `gulp --env=prod`
|
||||||
var argv = minimist(process.argv.slice(2));
|
var argv = minimist(process.argv.slice(2));
|
||||||
console.dir(argv);
|
console.dir(argv);
|
||||||
var prod = argv.env == 'prod' ? true : false;
|
// var prod = argv.env === 'prod' ? true : false;
|
||||||
|
var prod = true;
|
||||||
|
|
||||||
function handleError(err) {
|
function handleError(err) {
|
||||||
console.log(err.toString());
|
console.log(err.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
function scripts() {
|
async function scripts() {
|
||||||
return src(['./assets/scripts/main.js', './assets/scripts/redirect.js']) // './assets/scripts/shared_variables.js',
|
return src(['./assets/scripts/main.js', './assets/scripts/redirect.js']) // './assets/scripts/shared_variables.js',
|
||||||
// .pipe(concat('main.js'))
|
// .pipe(concat('main.js'))
|
||||||
.pipe(gulpif(prod, stripDebug()))
|
.pipe(gulpif(prod, stripDebug()))
|
||||||
@@ -34,9 +35,9 @@ function scripts() {
|
|||||||
.pipe(rename({suffix: '.min'}))
|
.pipe(rename({suffix: '.min'}))
|
||||||
.pipe(dest('./assets/dist/scripts/'));
|
.pipe(dest('./assets/dist/scripts/'));
|
||||||
|
|
||||||
};
|
}
|
||||||
|
|
||||||
function styles() {
|
async function styles() {
|
||||||
return src(['./assets/styles/app.scss'])
|
return src(['./assets/styles/app.scss'])
|
||||||
.pipe(sass().on('error', sass.logError))
|
.pipe(sass().on('error', sass.logError))
|
||||||
.pipe(autoprefixer({
|
.pipe(autoprefixer({
|
||||||
@@ -48,9 +49,9 @@ function styles() {
|
|||||||
// .pipe(cssmin())
|
// .pipe(cssmin())
|
||||||
.pipe(rename({suffix: '.min'}))
|
.pipe(rename({suffix: '.min'}))
|
||||||
.pipe(gulp.dest('./assets/dist/styles/'));
|
.pipe(gulp.dest('./assets/dist/styles/'));
|
||||||
};
|
}
|
||||||
|
|
||||||
function bower(){
|
async function bower(){
|
||||||
return src(mainBowerFiles({
|
return src(mainBowerFiles({
|
||||||
"overrides":{
|
"overrides":{
|
||||||
"masonry-layout":{
|
"masonry-layout":{
|
||||||
@@ -67,83 +68,25 @@ function bower(){
|
|||||||
}
|
}
|
||||||
}))
|
}))
|
||||||
.pipe(gulp.dest('./assets/dist/bower/'));
|
.pipe(gulp.dest('./assets/dist/bower/'));
|
||||||
};
|
}
|
||||||
|
|
||||||
function minsvg(){
|
async function minsvg(){
|
||||||
return src(['./assets/img/*.svg', '!./assets/img/edlp-loader-anim.svg'])
|
return src(['./assets/img/*.svg', '!./assets/img/edlp-loader-anim.svg'])
|
||||||
.pipe(svgmin())
|
.pipe(svgmin())
|
||||||
.pipe(gulp.dest('./assets/dist/img'));
|
.pipe(gulp.dest('./assets/dist/img'));
|
||||||
};
|
}
|
||||||
|
|
||||||
function svg(){
|
async function svg(){
|
||||||
return src('./assets/img/edlp-loader-anim.svg')
|
return src('./assets/img/edlp-loader-anim.svg')
|
||||||
.pipe(gulp.dest('./assets/dist/img'));
|
.pipe(gulp.dest('./assets/dist/img'));
|
||||||
};
|
}
|
||||||
|
|
||||||
function devwatch(){
|
function devwatch(){
|
||||||
watch('./assets/styles/*.scss', series('styles'));
|
watch('./assets/styles/*.scss', styles);
|
||||||
watch('./assets/styles/base/*.scss', series('styles'));
|
watch('./assets/styles/base/*.scss', styles);
|
||||||
watch('./assets/scripts/*.js', series('scripts'));
|
watch('./assets/scripts/*.js', scripts);
|
||||||
watch('./assets/img/*.svg', series('svg'));
|
watch('./assets/img/*.svg', svg);
|
||||||
}
|
}
|
||||||
|
|
||||||
// default gulp task
|
export default series(scripts, styles, svg, minsvg);
|
||||||
// , 'vars2sass' 'vars2js',
|
export { devwatch }
|
||||||
// gulp.task('default', ['bower', 'scripts', 'styles', 'svg'], function() {
|
|
||||||
// gulp.task('default', gulp.series('bower', 'scripts', 'styles', 'svg', function(done) {
|
|
||||||
// // gulp.watch('./assets/json/*.json', ['vars2js', 'styles', 'scripts']); //, 'vars2sass'
|
|
||||||
// gulp.watch('./assets/styles/*.scss', gulp.series('styles'));
|
|
||||||
// gulp.watch('./assets/styles/base/*.scss', gulp.series('styles'));
|
|
||||||
// gulp.watch('./assets/scripts/*.js', gulp.series('scripts'));
|
|
||||||
// gulp.watch('./assets/img/*.svg', gulp.series('svg'));
|
|
||||||
// done()
|
|
||||||
// }));
|
|
||||||
|
|
||||||
|
|
||||||
function defaultTask(){series('bower', 'scripts', 'styles', 'svg', 'minsvg', 'devwatch')};
|
|
||||||
|
|
||||||
export {
|
|
||||||
scripts as scripts,
|
|
||||||
styles as styles,
|
|
||||||
bower as bower,
|
|
||||||
svg as svg,
|
|
||||||
minsvg as minsvg,
|
|
||||||
devwatch as devwatch,
|
|
||||||
defaultTask as default
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// this task stays here just for memeomry about how to share variables between js and css
|
|
||||||
|
|
||||||
// gulp.task('vars2sass', function () {
|
|
||||||
// gulp.src('./assets/json/shared_variables.json')
|
|
||||||
// .pipe(jsonToSass({
|
|
||||||
// jsonPath: './assets/json/shared_variables.json',
|
|
||||||
// scssPath: './assets/styles/base/_shared_variables.scss'
|
|
||||||
// }));
|
|
||||||
// });
|
|
||||||
|
|
||||||
// this one is not working, works first run but then it's like it's caching the source
|
|
||||||
// gulp.task('variables2js', function() {
|
|
||||||
// gulp.src('./assets/scripts/shared_variables_model.js')
|
|
||||||
// .pipe(rename('shared_variables.js'))
|
|
||||||
// .pipe(data(function(file) {
|
|
||||||
// delete require.cache['./assets/json/shared_variables.json'];
|
|
||||||
// return require('./assets/json/shared_variables.json');
|
|
||||||
// }))
|
|
||||||
// .pipe(json2js())
|
|
||||||
// .pipe(gulp.dest('./assets/scripts/'));
|
|
||||||
// });
|
|
||||||
|
|
||||||
// gulp.task('vars2js', function() {
|
|
||||||
// gulp.src('./assets/json/shared_variables.json')
|
|
||||||
// .pipe(rename('shared_variables.js'))
|
|
||||||
// .pipe(through.obj(function (file, enc, cb) {
|
|
||||||
// // console.log('file',String(file.contents));
|
|
||||||
// // small pipe to wrappe json data into a js variable
|
|
||||||
// file.contents = new Buffer("edlp_vars = "+String(file.contents).trim()+";");
|
|
||||||
// cb(null, file);
|
|
||||||
// }))
|
|
||||||
// .pipe(gulp.dest('./assets/scripts/'));
|
|
||||||
// });
|
|
||||||
|
|||||||
@@ -7,7 +7,8 @@
|
|||||||
"license": "GPLv3",
|
"license": "GPLv3",
|
||||||
"homepage": "https://encyclopediedelaparole.org",
|
"homepage": "https://encyclopediedelaparole.org",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "gulp default"
|
"dev": "gulp devwatch",
|
||||||
|
"build": "gulp --env prod"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"gulp": "^5.0.0",
|
"gulp": "^5.0.0",
|
||||||
|
|||||||
Reference in New Issue
Block a user