B
B
bro-dev2015-08-26 05:09:23
JavaScript
bro-dev, 2015-08-26 05:09:23

How to attach other files to a stream in gulp?

I want to combine all javascript and coffee files into 1 file, the problem is that if you process everything together, then the coffeesrctip compiler swears.
there is no problem with css and less because less is backwards compatible

gulp.task('src/js/main.coffee', function () {
    gulp.src(path.src.js) //Найдем наш main файл
        .pipe(plumber())
        .pipe(rigger())
        .pipe(coffee({bare: false}))
        .pipe(uglify()) 
        .pipe(gulp.dest('build/js/')) //Выплюнем готовый файл в build
        .pipe(reload({stream: true})); //И перезагрузим сервер
});

I would like to do this but it doesn’t work, if it were possible for coffeesrcipt to leave comments, then it would be possible to put the rigger after and everything would be ok

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Andrey Khokhlov, 2015-08-26
@andrhohlov

See solutions here: stackoverflow.com/questions/21719833/how-to-add-sr...
And I recommend breaking everything down into separate tasks:
- compiling coffee
- combining js
(I would also take out minification as a separate task)
And make the third a task that runs them one by one.
This will turn out to be more flexible and modular, you can make various build options.

B
bro-dev, 2015-08-29
@xPomaHx

es = require("event-stream");

es = require("event-stream");
gulp.task('js:build', function () {
    
es.concat(
    gulp.src(path.src.js)
    ,gulp.src(path.src.coffee).pipe(rigger()).pipe(coffee())
    ).pipe(gulpConcat('main.js'))
 
       .pipe(rigger())
   
       .pipe(uglify()) //Сожмем наш js

        .pipe(gulp.dest(path.build.js)) //Выплюнем готовый файл в build
        .pipe(reload({stream: true})); //И перезагрузим сервер
});

In general, this is how a bit of shit code works

_
_ _, 2015-08-26
@AMar4enko

Use gulp-filter

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question