nimoc / gulp-book

Gulp 入门指南
1.82k stars 364 forks source link

压缩过后的dist目录结构如何与src目录结构保持一致? #42

Closed baininghan closed 6 years ago

baininghan commented 6 years ago

压缩过后的dist目录结构如何与src目录结构保持一致?

源码src下面的js文件目录结构比较复杂,如何在将js,css,images文件压缩到dist/目录下时,仍然保有src/下面的目录结构。

postbird commented 6 years ago

与目录结构无关呀,如果你不合并文件,就没影响呀?建议仔细看看 js/**/*.js 这种写法。

更多参考参照最后的写一个项目:https://github.com/onface/gulp-book/blob/master/chapter7.md,然后动手实践一下就OK

var uglify = require('gulp-uglify')

gulp.task('uglifyjs', function () {
    gulp.src('src/js/**/*.js')
        .pipe(uglify())
        .pipe(gulp.dest('dist/js'))
})

gulp.task('default', function () {
    gulp.watch('src/js/**/*.js', ['uglifyjs'])
})
baininghan commented 6 years ago

@postbird 我已经弄明白了,gulp.src('src/js/*/.js', {basic:'./src'})