B
B
Binarix2016-08-20 06:37:34
gulp.js
Binarix, 2016-08-20 06:37:34

How to include only the necessary js and css when building with Gulp?

Hello. I wondered about building a project on Gulp. When automatically connecting js and css through Bower, paths like "bower_components/normalize-css/normalize.css" are written to the downloaded packages, and there are a lot of unnecessary files. It is possible to pull files from packages with the main-bower-files plugin, but the paths will remain until the full packages. How can you rewrite paths?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
sergey, 2016-08-20
@zorro76

If you use main-bower-files then include only those files that you specified in the
example task:

gulp.task('styles:vendor', function() {
  gulp.src(mainBowerFiles({
          "overrides": {
              "normalize.css": {
                  "main": "./normalize.css"
              },

              "magnific-popup": {
                  "main": "./dist/magnific-popup.css"
              },

              "bootstrap": {
                  main: [
                      './dist/css/bootstrap.css',
                      './dist/fonts/*.*'
                  ]
              }
          }
  }))
  .pipe(cssFilter)
  .pipe(concat('vendor.css'))
  .pipe(gulpIf(env !== 'dev', minifyCSS()))
  .pipe(gulp.dest(outputDir + 'css'))
});

and there are no files :)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question