Created
March 9, 2016 18:21
-
-
Save sukrosono/83b0296a536cb923073b to your computer and use it in GitHub Desktop.
run grunt from different directory for building submodule
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = function(grunt) { | |
'use strict'; | |
var parent_module = '../../node_modules/'; | |
grunt.loadTasks(parent_module + 'grunt-contrib-watch/tasks'); | |
grunt.loadTasks(parent_module+'grunt-contrib-concat/tasks'); | |
grunt.loadTasks(parent_module+'grunt-contrib-uglify/tasks'); | |
grunt.initConfig({ | |
pkg: grunt.file.readJSON('../../package.json'), | |
concat: { | |
options: { | |
separator: '//#######################################################\n' | |
}, | |
dist: { | |
src: [ | |
'**/*.module.js', | |
'**/*.state.js', | |
'**/*.config.js', | |
'**/*.run.js', | |
'**/*.js' | |
], | |
dest: '../../dist/<%= pkg.name %>-submodule.js' | |
} | |
}, | |
uglify: { | |
options: { | |
banner: '/*! <%= pkg.name %>-submodule - v <%= pkg.version %> - by <%= pkg.author %>' + | |
' <%= grunt.template.today("dd-mmmm-yyyy")%> */\n', | |
sourceMap: true | |
}, | |
dist: { | |
files: { | |
'../../dist/<%= pkg.name %>-submodule.min.js': ['<%= concat.dist.dest %>'] | |
} | |
} | |
}, | |
watch: { | |
js: { | |
files: ['<%= concat.dist.src %>'] | |
}, | |
options: { | |
nospawn: true | |
} | |
// tasks: ['build'] not work here | |
} | |
}); | |
grunt.event.on('watch', function(action, filepath, target) { | |
grunt.log.writeln(target + ': ' + filepath + ' has ' + action+' defined by enter on grunt event'); | |
// achievable via | |
grunt.task.run('build'); | |
}); | |
grunt.registerTask('build', ['concat', 'uglify']); | |
grunt.registerTask('default', ['watch']); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
My env :