GulpJS copies folders and files from "foo" folder to "bar" folder and preserves the folder structure
I have a "foo" folder and "bar" folders, and I want to copy and run certain tasks in certain file files.
Problem: I can copy files, run tasks on them and keep the folder structure, but when I move files to the "bar" folder, it creates a "foo" folder inside the "bar" folder and stores all the copied files in it.
Tried it: tried to change base: '.'
to base: '../'
, but that just makes it compile everything to the parent folder bar
.
Folder structure:
.
├── foo
│ ├── app.js
│ ├── models
│ ├── public
│ │ ├── images
│ │ └── js
│ ├── routes
│ └── scss
├── bar
│ └── ...
└── gulpfile.js
Gulpjs.js file:
var gulp = require('gulp');
var uglify = require('gulp-uglify');
var sass = require('gulp-ruby-sass');
var cssmin = require('gulp-minify-css');
var rename = require('gulp-rename');
var htmlmin = require('gulp-htmlmin');
var paths = {
'ssjs' : ['foo/app.js', 'foo/routes/*.js', 'foo/models/*.js'],
'csjs' : ['foo/public/js/*.js'],
'sass' : ['foo/scss/*.scss', 'foo/scss/modules/*.scss'],
'html' : ['foo/public/*.html'],
'build' : 'bar',
'public': 'public'
};
gulp.task('ssjs', function() {
return gulp.src(paths.ssjs, {'base': '.'})
.pipe(uglify({'preserveComments': 'some'}))
.pipe(gulp.dest(paths.build));
});
gulp.task('csjs', function() {
return gulp.src(paths.csjs, {'base': '.'})
.pipe(uglify({'preserveComments': 'some'}))
.pipe(gulp.dest(paths.build));
});
gulp.task('sass', function() {
return gulp.src(paths.sass, {'base': '.'})
.pipe(sass())
.pipe(cssmin())
.pipe(gulp.dest(paths.build));
});
gulp.task('html', function() {
return gulp.src(paths.html, {'base': '.'})
.pipe(htmlmin({'collapseWhitespace': true}))
.pipe(gulp.dest(paths.build));
});
gulp.task('watch', function() {
gulp.watch(paths.ssjs, ['ssjs']);
gulp.watch(paths.csjs, ['csjs']);
gulp.watch(paths.scss, ['sass']);
});
gulp.task('default', [ 'ssjs', 'csjs', 'sass', 'html', 'watch' ]);
+3
source to share