Link to home
Start Free TrialLog in
Avatar of Leo Torres
Leo TorresFlag for United States of America

asked on

Grunt Copy file to another destination.

Hello I have this code below that copies all my files to a dist folder. Works fine but I would like to then copy the contents of that dist folder else where. Basically another copy to this location :
"/Volumes/Downloads/ProgramData/Code/AngularJS/Less4/json-server/public/"

There was a task i tried "multidest:" but it did not work. Any ideas?


'use strict';

module.exports = function (grunt) {

// Time how long tasks take. Can help when optimizing build times
require('time-grunt')(grunt);

//Load Multi dest
grunt.loadNpmTasks('grunt-multi-dest');

// Automatically load required Grunt tasks
require('jit-grunt')(grunt, {
  useminPrepare: 'grunt-usemin'
});

    // Define the configuration for all the tasks
    grunt.initConfig({
      pkg: grunt.file.readJSON('package.json'), 
//      pkg2: grunt.loadNpmTasks('grunt-multi-dest'),

        // Make sure code styles are up to par and there are no obvious mistakes
  jshint: {
    options: {
      jshintrc: '.jshintrc',
      reporter: require('jshint-stylish')
    },
    all: {
      src: [
        'Gruntfile.js',
        'app/scripts/{,*/}*.js'
      ]
    }
  },
 useminPrepare: {
      html: 'app/index.html',//'app/menu.html',

      useminPrepare: {
          html: 'app/index.html',//'app/menu.html',
          options: {
              dest: 'dist'
          }
      },

      // Concat
      concat: {
          options: {
              separator: ';'
          },

          // dist configuration is provided by useminPrepare
          dist: {}
      },

      // Uglify
      uglify: {
          // dist configuration is provided by useminPrepare
          dist: {}
      },

      cssmin: {
          dist: {}
      },

 },
      // Filerev
      filerev: {
          options: {
              encoding: 'utf8',
              algorithm: 'md5',
              length: 20
          },

          release: {
              // filerev:release hashes(md5) all assets (images, js and css )
              // in dist directory
              files: [{
                  src: [
                    'dist/scripts/*.js',
                    'dist/styles/*.css',
                  ]
              }]
          }
      },

      // Usemin
      // Replaces all assets with their revved version in html and css files.
      // options.assetDirs contains the directories for finding the assets
      // according to their relative paths
      usemin: {
          html: ['dist/*.html'],
          css: ['dist/styles/*.css'],
          options: {
              assetsDirs: ['dist', 'dist/styles']
          }
      },
 
        


copy: {
  dist: {
    cwd: 'app',
    src: [ '**','!styles/**/*.css','!scripts/**/*.js' ],
    dest: 'dist',
    expand: true
  },
  
  fonts: {
    files: [
      {
        //for bootstrap fonts
        expand: true,
        dot: true,
        cwd: 'bower_components/bootstrap/dist',
        src: ['fonts/*.*'],
        dest: 'dist'
      }, {
        //for font-awesome
        expand: true,
        dot: true,
        cwd: 'bower_components/font-awesome',
        src: ['fonts/*.*'],
        dest: 'dist'
      }
    ]
  }
},


//multidest: {
//        copy_some_files: {
//            tasks: [
//                "copy:dist"
//            ],
//            dest: ["/Volumes/Downloads/ProgramData/Code/AngularJS/Less4/json-server/public/"]
//        },
//    },



watch: {
  copy: {
    files: [ 'app/**', '!app/**/*.css', '!app/**/*.js','conFusion/*.js','app/views/**'],
    tasks: [ 'build' ]
  },
  
  scripts: {
    files: ['app/scripts/app.js','app/scripts/*.js'],
    tasks:[ 'build']
  },
  
  styles: {
    files: ['app/styles/mystyles.css'],
    tasks:['build']
  },
  
  livereload: {
    options: {
      livereload: '<%= connect.options.livereload %>'
    },
    
    files: [
      'app/{,*/}*.html',
      '.tmp/styles/{,*/}*.css',
      'app/images/{,*/}*.{png,jpg,jpeg,gif,webp,svg}'
    ]
  }
},

connect: {
  options: {
    port: 9001,
    //hostname: '0.0.0.0',  // Change this to '0.0.0.0' to access the server from outside.
    hostname: 'localhost',
    livereload: 35730 //29
  },
  
  dist: {
    options: {
      open: true,
      base:{
        path: 'dist',
        options: {
          index:  'index.html',//'menu.html', //'dishdetail.html',
          maxAge: 300000
        }
      }
    }
  }
},        
        

clean: {
  build: {
    src: [ 'dist/']
  }
},



 //copy2: {
 //       somefiles: {
 //           src: "app",
 //           dest: "/Volumes/Downloads/ProgramData/Coursera/AngularJS/Week4v2/json-server/public/"
 //       }
 //}
        //,


      



 });



grunt.registerTask('build', [
  'clean',
  'jshint',
  'useminPrepare',
  'concat',
  'cssmin',
  'uglify',
  'copy',
  'filerev',
  'usemin'
]);

    grunt.registerTask('serve',['build','connect:dist','watch']);

    grunt.registerTask('default',['build']);

};

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of BigRat
BigRat
Flag of France image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial