Last active
August 29, 2015 14:09
-
-
Save danmindru/8eb91c105c8ddd973edb to your computer and use it in GitHub Desktop.
Loading AngularJS modules
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
| /* | |
| * Configuration variables | |
| */ | |
| module.exports = { | |
| source_dir: './src/', | |
| build_dir: './build/', | |
| compile_dir: './application/', | |
| build: { | |
| vendor_js: [] | |
| }, | |
| module_file_order: [ | |
| '**/*.init.js', | |
| '**/*.config.js', //routes & constants, etc | |
| '**/*.run.js', | |
| '**/*.service.js', //factories & providers, etc | |
| '**/*.controller.js', | |
| '**/*.directive.js', | |
| '**/*.filter.js' | |
| ] | |
| }; |
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) { | |
| /* | |
| * Include grunt configuration | |
| */ | |
| var gruntConfig = require( './grunt.config.js' ); | |
| /* | |
| * Helpers (preparing for grunt util deprecation) | |
| */ | |
| var glob = require('glob'); | |
| /* | |
| * Configuration | |
| */ | |
| var gruntTasks = { | |
| pkg: grunt.file.readJSON('package.json'), | |
| copy: { | |
| build_app_js: { | |
| src: [ | |
| findModuleFilesIn('./src/app/'), | |
| findModuleFilesIn('./src/common/'), | |
| ], | |
| dest: '<%= build_dir %>' | |
| }, | |
| build_vendor_js: { | |
| src: ['<%= build.vendor_js %>'], | |
| dest: '<%= build_dir %>' | |
| }, | |
| build_index: { | |
| src: ['./src/index.html'], | |
| dest: '<%= build_dir %>', | |
| expand: true, | |
| flatten: true, | |
| options: { | |
| process: processBuild | |
| } | |
| }, | |
| build_karma: { | |
| src: ['./karma.conf.js'], | |
| dest: '<%= build_dir %>', | |
| options: { | |
| process: processBuild | |
| } | |
| } | |
| } | |
| }; | |
| grunt.initConfig( | |
| grunt.util._.extend(gruntTasks, gruntConfig) | |
| ); | |
| /* | |
| * Helpers | |
| */ | |
| function findModuleFilesIn(modulePath){ | |
| var output = [], | |
| i; | |
| for(i = 0; i <= gruntConfig.module_file_order.length-1; i++){ | |
| output.push(modulePath + gruntConfig.module_file_order[i]); | |
| } | |
| return output; | |
| } | |
| function processBuild(content){ | |
| var buildScripts = []; | |
| var customModules = gruntConfig.build.vendor_js | |
| .concat(findModuleFilesIn('./src/app/')) | |
| .concat(findModuleFilesIn('./src/common/')); | |
| customModules.forEach(function(module){ | |
| glob(module, { sync: true }, function(err, files){ | |
| if(files.length > 0){ | |
| buildScripts = files.concat(buildScripts); | |
| } | |
| }); | |
| }); | |
| return grunt.template.process(content, { | |
| data: { | |
| scripts: buildScripts.reverse() | |
| } | |
| }); | |
| } | |
| /* | |
| * Tasks | |
| */ | |
| grunt.registerTask('build', ['copy:build_app_js', 'copy:build_vendor_js', 'copy:build_index', 'copy:build_karma']); | |
| }; |
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
| <!DOCTYPE html> | |
| <html lang="en" xmlns="http://www.w3.org/1999/xhtml" data-ng-controller="rootController"> | |
| <head> | |
| <title>AngularJS</title> | |
| <!-- General META --> | |
| <meta charset="utf-8"> | |
| <meta http-equiv="Content-type" content="text/html;charset=UTF-8"> | |
| <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> | |
| <meta name="viewport" content="width=device-width,initial-scale=1"> | |
| <!-- Semantic META --> | |
| <meta name="description" content="A study of AngularJS modularity and organization"> | |
| <meta name="author" content="Dan Mindru"> | |
| <meta name="keywords" content="AngularJS, module, boilerplate"> | |
| </head> | |
| <body class="ng-cloak"> | |
| </body> | |
| <!-- Render Scripts --> | |
| <% | |
| scripts.forEach(function (script){ | |
| %><script type="text/javascript" src="<%= script %>"></script><% | |
| }); | |
| %> | |
| </html> |
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
| // Karma configuration | |
| // Generated on Wed Nov 19 2014 02:03:45 GMT+0100 (CET) | |
| module.exports = function(config) { | |
| config.set({ | |
| // base path that will be used to resolve all patterns (eg. files, exclude) | |
| basePath: '', | |
| // frameworks to use | |
| // available frameworks: https://npmjs.org/browse/keyword/karma-adapter | |
| frameworks: ['jasmine'], | |
| // list of files / patterns to load in the browser | |
| files: [ | |
| <% scripts.forEach(function (script){ | |
| %>'<%= script %>', | |
| <% });%> | |
| './src/**/*.spec.js' | |
| ], | |
| // list of files to exclude | |
| exclude: [ | |
| ], | |
| // preprocess matching files before serving them to the browser | |
| // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor | |
| preprocessors: { | |
| }, | |
| // test results reporter to use | |
| // possible values: 'dots', 'progress' | |
| // available reporters: https://npmjs.org/browse/keyword/karma-reporter | |
| reporters: ['progress'], | |
| // web server port | |
| port: 9876, | |
| // enable / disable colors in the output (reporters and logs) | |
| colors: true, | |
| // level of logging | |
| // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG | |
| logLevel: config.LOG_INFO, | |
| // enable / disable watching file and executing tests whenever any file changes | |
| autoWatch: false, | |
| // start these browsers | |
| // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher | |
| browsers: ['Chrome', 'Firefox', 'Safari', 'PhantomJS', 'Opera'], | |
| // Continuous Integration mode | |
| // if true, Karma captures browsers, runs the tests and exits | |
| singleRun: true | |
| }); | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment