Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Make grunt bower get minified version from "bower_components"

Tags:

gruntjs

bower

In my GruntFile.js I have bower task:

bower: {
    dev: {
        dest: 'lib'// will get stuff from 'bower_components' to 'lib' folder
    }
},

So when I do: grunt bower it transforms some stuff from bower_component folder to lib.. so I end up having files like: angular.js in the /lib.

But it does not copy "angular.min.js", which sits in bower_component.

Q: How can I configure grunt bower task to copy minified v of files too?

I do not want to put minify/uglify tasks to GruntFile just yet. Since those files are already minified in bower_components.

like image 511
ses Avatar asked Oct 31 '22 08:10

ses


1 Answers

You should use the bower task just to download bower components and add a copy task to move files around as needed.

Install grunt-contrib-copy

npm install grunt-contrib-copy --save-dev

And use it in your grunt file:

grunt.loadNpmTasks('grunt-contrib-copy');

grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),  
    /* more tasks... */
    copy: {
      main: {
        files: [
          // includes files within path
          {expand: true, src: ['path/*'], dest: 'dest/', filter: 'isFile'},

          // includes files within path and its sub-directories
          {expand: true, src: ['path/**'], dest: 'dest/'},

          // makes all src relative to cwd
          {expand: true, cwd: 'path/', src: ['**'], dest: 'dest/'},

          // flattens results to a single level
          {expand: true, flatten: true, src: ['path/**'], dest: 'dest/', filter: 'isFile'},
        ],
      },
    }
});

You can configure it to copy just what the **.min.js files.

like image 89
Remo H. Jansen Avatar answered Nov 15 '22 10:11

Remo H. Jansen