Soil Clock / Bower link: What is the most appropriate way to use a Grunt watch with Bower when developing a Bower component?

Problem

I am currently working on a project in which we have a parent web application (for example, an AngularJS application) and several Bower child modules (containing Javascript, SASS, images, etc.) that are included in the parent using Bower .

For example, the parent bower.json looks like this:

{
    "name": "parent-app",
    "version": "1.0.0",
    "dependencies": {
        "child-1-module": "1.0.0",
        "child-2-module": "1.0.0"
    }
}

When you install "bower install" on the parent module, the child modules will be installed on:

bower_components/child-1-module
bower_components/child-2-module




Then we use the 'bower link' for each of the child modules.

Then the parent channel bower link-1-module and bower link child-2-module for the parent to create local soft links, such as:

bower_components/child-1-module -> /some/where/else/child-1-module
bower_components/child-2-module -> /some/where/else/child-2-module

.


Grunt grunt-contrib-watch , Grunt , , .

Gruntfile.js, .js, "jshint", " " :

grunt.initConfig({

    // Watches files for changes and runs tasks based on the changed files
    watch: {
        js: {
            files: [
                'scripts/{,*/}*.js', 
            ],
            tasks: ['newer:jshint:all'],
            options: {
                livereload: true
            }
        }
    }
}


, , . , / .


1: bower_components

Gruntfile, .js bower_components, :

grunt.initConfig({

    // Watches files for changes and runs tasks based on the changed files
    watch: {
        js: {
            files: [
                'scripts/**/*.js', 
                'bower_components/**/*.js'
            ],
            tasks: ['newer:jshint:all'],
            options: {
                livereload: true
            }
        }
    }
}


( .js), - EMFILE: (. ).

, , Grunt , :

'bower_components/child-1-module/**/*.js'


2:

Gruntfile.js , .

, "livereload", .

"Gruntfile.js" child-module-1

grunt.initConfig({
    watch: {
        js: {
            files: ['scripts/**/*.js'],
            tasks: ['livereloadEvent:js', 'newer:jshint:all']
        }
    }
}
grunt.registerTask('livereloadEvent', function() {
    // create a 'livereload/livereload.{arg}' file for the event specified
    grunt.file.mkdir('livereload');
    for(var i = 0; i < this.args.length; i++) {
        // contents of the file is the current timestamp
        grunt.file.write('livereload/livereload.'+ this.args[i], new Date());
    }
});


:

'bower_components/**/livereload/livereload.js'


. , .

, .


...

? ?

+4
1

, , 2.

  • , bower Angular.

  • . grunt watch, , grunt watch, .

  • , grunt /dist.

  • /dist , , .

, , bower, :

watch: {
    bower_components: {
        files: ['./bower_components/orgname-*/dist/*.js'],
        tasks: ['newer:copy']
    }
}

, " ", .

0

All Articles