Created
December 6, 2016 08:26
-
-
Save moinsam/10e5954e978af83e204caf286e0a663d to your computer and use it in GitHub Desktop.
Gruntfile for profileing the project building
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) { | |
// ignore other code only the related code to profile your build is there | |
grunt.loadNpmTasks('grunt-ng-constant'); | |
// Define the configuration for all the tasks | |
grunt.initConfig({ | |
// irrevalant code omitted | |
ngconstant: { | |
options: { | |
space: ' ', | |
wrap: '"use strict";\n\n {%= __ngModule %}', | |
name: 'config' | |
}, | |
// Environment targets | |
development: { | |
options: { | |
dest: '<%= yeoman.app %>/scripts/config.js' | |
}, | |
constants: { | |
ENV: { | |
name: 'development', | |
// add your environment related value here | |
} | |
} | |
}, | |
testing: { | |
options: { | |
dest: '<%= yeoman.app %>/scripts/config.js' | |
}, | |
constants: { | |
ENV: { | |
name: 'testing', | |
// add your environment related value here | |
} | |
} | |
}, | |
production: { | |
options: { | |
dest: '<%= yeoman.app %>/scripts/config.js' | |
}, | |
constants: { | |
ENV: { | |
name: 'production', | |
// add your environment related value here | |
} | |
} | |
} | |
}, | |
}); | |
grunt.registerTask('serve', 'Compile then start a connect web server', function (environment) { | |
if (environment !== undefined) { | |
return grunt.task.run(['build:'+environment, 'connect:dist:keepalive']); | |
} | |
grunt.task.run([ | |
'clean:server', | |
'wiredep', | |
'bowercopy', | |
'concurrent:server', | |
'postcss:server', | |
'connect:livereload', // this automatically open the web app on browserx | |
'watch' | |
]); | |
}); | |
grunt.registerTask('server', 'DEPRECATED TASK. Use the "serve" task instead', function (target) { | |
grunt.log.warn('The `server` task has been deprecated. Use `grunt serve` to start a server.'); | |
grunt.task.run(['serve:' + target]); | |
}); | |
grunt.registerTask('build', 'Compile and build for environment provided', function(environment) { | |
if (environment === undefined) { | |
environment = "development"; | |
} | |
console.log("build for development environment"); | |
grunt.task.run([ | |
'clean:dist', | |
'ngconstant:'+environment, // development, testing, production | |
// omitted code from here | |
]); | |
}); | |
grunt.registerTask('default', [ | |
'newer:jshint', | |
'newer:jscs', | |
'test', | |
'build' | |
]); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
to run use this command grunt clean build:development, grunt clean serve:development. Available values are "development", "testing", "production"