Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript Gulp/Grunt Question

  • This topic is empty.
Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #169091
    Steven Morgan
    Participant

    Pretty sure it’s the same in both packages.
    How do I use variables for file names?

    For instance, if I have:
    file1.js
    file2.js
    file3.js

    And I want to give that a destination of:
    file1.min.js
    file2.min.js
    file3.min.js

    return gulp.src('js/file1.js')
        .pipe(uglify())
        .pipe(concat('file1.min.js'))
        .pipe(gulp.dest('js/build'));
    

    Without having to rewire this 3 different times with the 3 different file names.

    #169112
    shaneisme
    Participant

    Just use the * as a wild-card and you’re good.

    return gulp.src('js/*.js)

    #169119
    Steven Morgan
    Participant

    I thought that would work, but it just takes all of the files and runs them into *.js

    #169122
    Alen
    Participant
    #169146
    maxisix
    Participant

    You can use an array like this

    gulp.src([‘file1.js’, ‘file2.js’]).pipe(…)

    If you want you can take a look on my gulpfile

    https://github.com/maxisix/maxisix-gulp-template/blob/master/gulpfile.js

    #178758
    garystorey
    Participant

    If you haven’t already check out the gulp-rename plugin.

Viewing 6 posts - 1 through 6 (of 6 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.