Last active
August 29, 2015 14:01
-
-
Save rileytg/11543159 to your computer and use it in GitHub Desktop.
require js config for a yeoman project
This file contains 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
# grunt buildcontrol | |
npm install --save-dev grunt-build-control | |
# Require JS | |
npm install --save-dev grunt-processhtml grunt-contrib-requirejs | |
bower install --save requirejs | |
# Jasmine Testing | |
npm install --save-dev grunt-template-jasmine-requirejs grunt-contrib-jasmine |
This file contains 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
var require = { | |
paths: { | |
jquery: '../bower_components/jquery/dist/jquery', | |
requirejs: '../bower_components/requirejs/require' | |
}, | |
shim: {} | |
} | |
// todo add shim example |
This file contains 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
{ | |
buildcontrol: { | |
options: { | |
dir: 'dist', | |
commit: true, | |
push: true, | |
message: 'Built %sourceName% from commit %sourceCommit% on branch %sourceBranch%' | |
}, | |
pages: { | |
options: { | |
remote: 'https://github.com/fcflamingo/fcflamingo.git', | |
branch: 'gh-pages' | |
} | |
}, | |
local: { | |
options: { | |
remote: '../', | |
branch: 'build' | |
} | |
} | |
}, | |
processhtml: { | |
options: { | |
commentMarker: 'process' | |
}, | |
dist: { | |
files: { | |
'<%= config.dist %>/index.html': '<%= config.dist %>/index.html' | |
} | |
} | |
}, | |
requirejs: { | |
compile: { | |
options: { | |
almond: true, | |
baseUrl: '<%= config.app %>/scripts', | |
mainConfigFile: '<%= config.app %>/scripts/config.js', | |
name: 'main', | |
include: ['main', '../bower_components/requirejs/require'], | |
insertRequire: ['main'], | |
out: '<%= config.dist %>/scripts/optimized.js', | |
preserveLicenseComments: false, | |
wrap: true | |
} | |
} | |
}, | |
jasmine: { | |
taskName: { | |
options: { | |
specs: 'spec/*Spec.js', | |
template: require('grunt-template-jasmine-requirejs'), | |
templateOptions: { | |
requireConfigFile: 'app/scripts/config.js', | |
requireConfig: { | |
baseUrl: 'app/scripts' | |
} | |
} | |
} | |
} | |
} | |
} | |
//// later on in the tasks config | |
grunt.registerTask('build', [ | |
'clean:dist', | |
'useminPrepare', | |
'concurrent:dist', | |
'autoprefixer', | |
'concat', | |
'cssmin', | |
'uglify', | |
'copy:dist', | |
'requirejs', // **** | |
'processhtml', // **** | |
'rev', | |
'usemin', | |
'htmlmin' | |
]); | |
// change the grunt.registerTask('test'... to match this: | |
grunt.registerTask('test', function (target) { | |
grunt.task.run([ | |
'jasmine' | |
]); | |
}); |
This file contains 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
<!-- process:js scripts/optimized.js --> | |
<script src="scripts/config.js" type="text/javascript"></script> | |
<script data-main="scripts/main" src="bower_components/requirejs/require.js"></script> | |
<!-- /process --> |
This file contains 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
require([], function() { | |
if(window.console) console.log("Welcome") | |
}) |
This file contains 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
define([], function() { | |
return {} | |
}) |
This file contains 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
define(['myModule'], function (myModule) { | |
describe('Give it some context', function () { | |
describe('maybe a bit more context here', function () { | |
it('should run here few assertions when x happens', function () { | |
// assertions | |
}) | |
it('should run here few other assertions when y happens', function () { | |
// assertions | |
}) | |
}) | |
}) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment