Skip to content

Commit

Permalink
feat(build): Moved config to separate file
Browse files Browse the repository at this point in the history
User configuration of build tasks is no longer in the Gruntfile.
Instead, a `build.config.js` contains the necessary configuration
parameters. This split will ease future upgrades as well as provide a
less intimidating entry point for new ngBoilerplate users.
  • Loading branch information
Josh David Miller committed Jun 24, 2013
1 parent 7af6729 commit ff5d8b5
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 59 deletions.
68 changes: 9 additions & 59 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,16 @@ module.exports = function ( grunt ) {
grunt.loadNpmTasks('grunt-ngmin');
grunt.loadNpmTasks('grunt-html2js');

/**
* Load in our build configuration file.
*/
var userConfig = require( './build.config.js' );

/**
* This is the configuration object Grunt uses to give each plugin its
* instructions.
*/
grunt.initConfig({
/**
* The `build_dir` folder is where our projects are compiled during
* development and the `compile_dir` folder is where our app resides once it's
* completely built.
*/
build_dir: 'build',
compile_dir: 'bin',

var taskConfig = {
/**
* We read in our `package.json` file so we can access the package name and
* version. It's already there, so we don't repeat ourselves here.
Expand All @@ -54,55 +51,6 @@ module.exports = function ( grunt ) {
' */\n'
},

/**
* This is a collection of file patterns that refer to our app code (the
* stuff in `src/`). These file paths are used in the configuration of
* build tasks. `js` is all project javascript, less tests. `ctpl` contains
* our reusable components' (`src/common`) template HTML files, while
* `atpl` contains the same, but for our app's code. `html` is just our
* main HTML file, `less` is our main stylesheet, and `unit` contains our
* app's unit tests.
*/
app_files: {
js: [ 'src/**/*.js', '!src/**/*.spec.js' ],
jsunit: [ 'src/**/*.spec.js' ],

coffee: [ 'src/**/*.coffee', '!src/**/*.spec.coffee' ],
coffeeunit: [ 'src/**/*.spec.coffee' ],

atpl: [ 'src/app/**/*.tpl.html' ],
ctpl: [ 'src/common/**/*.tpl.html' ],

html: [ 'src/index.html' ],
less: 'src/less/main.less'
},

/**
* This is the same as `app_files`, except it contains patterns that
* reference vendor code (`vendor/`) that we need to place into the build
* process somewhere. While the `app_files` property ensures all
* standardized files are collected for compilation, it is the user's job
* to ensure non-standardized (i.e. vendor-related) files are handled
* appropriately in `vendor_files.js`.
*
* The `vendor_files.js` property holds files to be automatically
* concatenated and minified with our project source files.
*
* The `vendor_files.css` property holds any CSS files to be automatically
* included in our app.
*/
vendor_files: {
js: [
'vendor/angular/angular.js',
'vendor/angular-bootstrap/ui-bootstrap-tpls.min.js',
'vendor/placeholders/angular-placeholders-0.0.1-SNAPSHOT.min.js',
'vendor/angular-ui-router/release/angular-ui-router.js',
'vendor/angular-ui-utils/modules/route/route.js'
],
css: [
]
},

/**
* Creates a changelog on a new version.
*/
Expand Down Expand Up @@ -561,7 +509,9 @@ module.exports = function ( grunt ) {
}
}
}
});
};

grunt.initConfig( grunt.util._.extend( taskConfig, userConfig ) );

/**
* In order to make it safe to just compile or copy *only* what was changed,
Expand Down
61 changes: 61 additions & 0 deletions build.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/**
* This file/module contains all configuration for the build process.
*/
module.exports = {
/**
* The `build_dir` folder is where our projects are compiled during
* development and the `compile_dir` folder is where our app resides once it's
* completely built.
*/
build_dir: 'build',
compile_dir: 'bin',

/**
* This is a collection of file patterns that refer to our app code (the
* stuff in `src/`). These file paths are used in the configuration of
* build tasks. `js` is all project javascript, less tests. `ctpl` contains
* our reusable components' (`src/common`) template HTML files, while
* `atpl` contains the same, but for our app's code. `html` is just our
* main HTML file, `less` is our main stylesheet, and `unit` contains our
* app's unit tests.
*/
app_files: {
js: [ 'src/**/*.js', '!src/**/*.spec.js' ],
jsunit: [ 'src/**/*.spec.js' ],

coffee: [ 'src/**/*.coffee', '!src/**/*.spec.coffee' ],
coffeeunit: [ 'src/**/*.spec.coffee' ],

atpl: [ 'src/app/**/*.tpl.html' ],
ctpl: [ 'src/common/**/*.tpl.html' ],

html: [ 'src/index.html' ],
less: 'src/less/main.less'
},

/**
* This is the same as `app_files`, except it contains patterns that
* reference vendor code (`vendor/`) that we need to place into the build
* process somewhere. While the `app_files` property ensures all
* standardized files are collected for compilation, it is the user's job
* to ensure non-standardized (i.e. vendor-related) files are handled
* appropriately in `vendor_files.js`.
*
* The `vendor_files.js` property holds files to be automatically
* concatenated and minified with our project source files.
*
* The `vendor_files.css` property holds any CSS files to be automatically
* included in our app.
*/
vendor_files: {
js: [
'vendor/angular/angular.js',
'vendor/angular-bootstrap/ui-bootstrap-tpls.min.js',
'vendor/placeholders/angular-placeholders-0.0.1-SNAPSHOT.min.js',
'vendor/angular-ui-router/release/angular-ui-router.js',
'vendor/angular-ui-utils/modules/route/route.js'
],
css: [
]
},
};

0 comments on commit ff5d8b5

Please sign in to comment.