In my gulpfile so far, I am minifying the Javascript code using uglify and using sourcemaps to keep the traces. The problem is that all the files are going into the root of the build
directory. I would like Gulp to create appropriate directories under the build directory same as they are copied from.
Here is my code so far:
var gulp = require('gulp'),
javascript_minify = require('gulp-uglify'),
sourcemaps = require('gulp-sourcemaps'),
files = {
javascript: ['controllers/*.js', 'directives/*.js', 'services/*.js', 'app.js'],
html: [], // to be added
css: [] // to be added
};
gulp.task('javascript-minify', function () {
gulp.src(files.javascript)
.pipe(sourcemaps.init())
.pipe(javascript_minify())
.pipe(sourcemaps.write())
.pipe(gulp.dest('build'));
});
As explained earlier, here is the visual of the problem:
How do I fix this?
I think you just need to pass base
as second param in source...
gulp.task('javascript-minify', function () {
gulp.src(files.javascript, {base: "."})
.pipe(sourcemaps.init())
.pipe(javascript_minify())
.pipe(sourcemaps.write())
.pipe(gulp.dest('build'));
});
That should help you.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.