Created
September 6, 2013 11:41
-
-
Save shadow-fox/6462692 to your computer and use it in GitHub Desktop.
Requirejs failing.
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 crypto = require('crypto'); | |
var fs = require('fs'); | |
function createFileSha(filenane) { | |
var sha = crypto.createHash('sha1'); | |
return sha.update(fs.readFileSync(filenane)); | |
} | |
module.exports = function(grunt) { | |
grunt.initConfig({ | |
meta: { | |
version: '0.0.1' | |
}, | |
jshint: { | |
options: { | |
"asi" : false, | |
"bitwise" : true, | |
"boss" : false, | |
"curly" : true, | |
"debug": false, | |
"devel": false, | |
"eqeqeq": true, | |
"evil": false, | |
"expr": true, | |
"forin": false, | |
"immed": true, | |
"latedef" : false, | |
"laxbreak": false, | |
"multistr": true, | |
"newcap": true, | |
"noarg": true, | |
"node" : true, | |
"browser": true, | |
"noempty": false, | |
"nonew": true, | |
"onevar": false, | |
"plusplus": false, | |
"regexp": false, | |
"strict": false, | |
"sub": false, | |
"trailing" : true, | |
"undef": true, | |
globals: { | |
jQuery: true, | |
Backbone: true, | |
_: true, | |
$: true, | |
require: true, | |
define: true | |
} | |
}, | |
js: ['public/javascripts/**/*.js', 'source/**/*.js'] | |
}, | |
requirejs: { | |
js: { | |
options: { | |
baseUrl: "public/javascripts", | |
mainConfigFile: "public/javascripts/main.js", | |
name: 'main', | |
out: "public/assets/main.js" | |
} | |
}, | |
css: { | |
options: { | |
baseUrl: 'public/css', | |
cssIn: "public/stylesheets/main.css", | |
out: "public/assets/main.css", | |
cssImportIgnore: null, | |
optimizeCss: 'default' | |
} | |
} | |
}, | |
hashres: { | |
options: { | |
fileNameFormat: '${name}-${hash}.${ext}' | |
}, | |
prod: { | |
src: [ | |
'public/assets/main.js', | |
'public/assets/main.css' | |
], | |
dest: { src: 'tools/client/index.js', out: 'source/client/index.js' } | |
} | |
} | |
}); | |
// Laoded tasks | |
grunt.loadNpmTasks('grunt-contrib-jshint'); | |
grunt.loadNpmTasks('grunt-contrib-requirejs'); | |
grunt.loadNpmTasks('grunt-hashres'); | |
// Default task. | |
grunt.registerTask('default', ['jshint', 'requirejs', 'hashres']); | |
}; |
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 (require) { | |
var Backbone = require('Backbone'); | |
var HeaderView = Backbone.View.extend({ | |
template: require('jade!./../templates/HeaderView'), | |
render: function () { | |
this.$el.html(this.template({title: 'TheMailer'})); | |
return this; | |
} | |
}); | |
return HeaderView; | |
}); |
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.config({ | |
jade: { | |
templateExtension: 'jade', | |
disableI18n: true, | |
disableHelpers: true | |
}, | |
shim: { | |
'jQuery': { | |
exports: '$' | |
}, | |
'Underscore': { | |
exports: '_' | |
}, | |
'Backbone': { | |
deps: ['Underscore', 'jQuery'], | |
exports: 'Backbone' | |
}, | |
'Jade': { | |
exports: 'Jade' | |
}, | |
'ApplicationRouter': { | |
deps: ['jQuery', 'Underscore', 'Backbone'] | |
} | |
}, | |
paths: { | |
jQuery: './../components/jquery/jquery', | |
Underscore: './../components/underscore/underscore', | |
Backbone: './../components/backbone/backbone', | |
Jade: './../components/require-jade/jade', | |
Stylus: './../components/require-stylus/require-stylus' | |
} | |
}); | |
require(['core/router', 'core/client', 'Backbone'], function (Router, client, Backbone) { | |
var app = { | |
root: '/' | |
}; | |
window.Router = new Router(); | |
client.setup(window, app); | |
Backbone.history.start({ pushState: true }); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment