Skip to content

Instantly share code, notes, and snippets.

@brianjmiller
Last active August 29, 2015 14:01
Show Gist options
  • Save brianjmiller/a92f73c1277bcafd5f84 to your computer and use it in GitHub Desktop.
Save brianjmiller/a92f73c1277bcafd5f84 to your computer and use it in GitHub Desktop.
Backbone-stack updates
{
"name": "-client",
"version": "1.0.0",
"private": "true",
"dependencies": {
"requirejs": "2.1.11",
"almond": "0.2.9",
"jquery": "1.11.0",
"jquery.cookie": "1.4.0",
"handlebars": "1.3.0",
"backbone": "1.1.2",
"backbone-relational": "0.8.8",
"backbone.subviews": "0.7.1",
"underscore": "1.6.0",
"bootstrap": "3.1.1",
"Font-Awesome": "4.0.3",
"backgrid": "git://github.com/wyuenho/backgrid#master",
"momentjs": "2.5.1",
"showdown": "0.3.1",
"cryptojslib": "3.1.2"
}
}
/*global module:false*/
module.exports = function(grunt) {
// Project configuration.
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
/**
* Watching
* ========
*
* Automatically tests and builds your code
* whenever you edit the source files or tests.
*/
watch: {
scripts: {
files: ['src/**/!(templates).js', 'src/**/*.html', 'src/**/*.less', 'tests/**/*.js', 'require.config.js'],
tasks: ['build'],
options: {
interrupt: true
}
}
},
/**
* Linting
* =======
*
* Catch errors quickly with JS Hint
*/
jshint: {
all: ['Gruntfile.js', 'src/**/!(templates).js', 'test/!(libs)/*.js'],
options: {
es5: false, // Allows EcmaScript5 syntax
curly: true, // Always use curlys {}
eqeqeq: true, // No more == for you, === only
immed: true, // prohibits the use of immediate function invocations without wrapping them in parentheses
latedef: true, // no setting variables before they are defined
newcap: true, // Always call constructors with a Cap
noarg: true, // prohibits arguments.caller and arguments.callee
sub: true, // This option suppresses warnings about using [] notation when it can be expressed in dot notation: person['name'] vs. person.name.
undef: true, // prohibits the use of explicitly undeclared variables
boss: true, // Allows assignments in ifs - if (a = 10) {}
eqnull: true, // Allows == null check for null or undefined
browser: true, // Sets up globals for browser like window and document
maxdepth: 6, // Max nesting of methods 3 layers deep
unused: true, // Warns on unused variables
expr: true, // Allowed for chais expect(false).to.be.false; assertion style.
devel: true, // Allows console.log's etc
trailing: true, // Prohibits trailing whitespace
bitwise: true,
forin: false,
noempty: true,
nomen: false,
onevar: true,
plusplus: false,
regexp: false,
strict: false,
debug: false, // allow debugger statements
globals: {
require: true,
define: true,
requirejs: true,
suite: true,
expect: true,
test: true,
setup: true,
teardown: true,
sinon: true,
mocha: true,
AppConfig: true
}
}
},
/**
* Testing
* =======
*
* Run your unit tests in headless phantomJS
*/
mocha: {
index: ['test/test-runner.html']
},
/**
* Templating
* ==========
*
* Pre-compile your handlebars templates
*/
handlebars: {
compile: {
options: {
amd: true,
wrapped: true,
processName: function(filename) {
return filename.replace("src/templates/", "");
}
},
files: {
"src/templates.js": "src/**/*.html"
}
}
},
/**
* Building
* ========
*
* Build your amd modules into a single minified JS file
*/
requirejs: {
compile: {
options: {
name: "../bower_components/almond/almond", // Path to almond requirejs production runner for built js
baseUrl: "src",
mainConfigFile: "./require.config.js",
include: ["main"], // Include the main module defined
insertRequire: ["main"], // Add a require step in at the end for the main module.
wrap: true, // Wrap everything up in a closure
generateSourceMaps: true, // Experimental
preserveLicenseComments: false, // Needs turned off for generateSourceMaps
optimize: "uglify2", // Supports generateSourceMaps
out: "../public/assets/javascripts/build.js",
logLevel: 2
}
}
},
/**
* Stylesheets
* ===========
*
* Compile, concat & lint css and less files into a single output file
*/
less: {
dist: {
options: {
paths: ["src/styles"],
yuicompress: true
},
files: {
'../public/assets/stylesheets/styles.css': 'src/styles/main.less'
}
}
},
copy: {
dist: {
files: [
{
expand: true,
cwd: 'bower_components/Font-Awesome/fonts/',
src: '**',
dest: '../public/assets/fonts/'
}
]
}
}
});
// Version assets
grunt.registerTask('version-assets', 'version the static assets just created', function() {
var Version = require("node-version-assets"),
versionInstance = new Version({
assets: [
'../public/assets/stylesheets/styles.css',
'../public/assets/javascripts/build.js'
],
grepFiles: ['../public/dev-index.html']
}),
cb = this.async(); // grunt async callback
versionInstance.run(cb);
});
// Load Tasks
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-handlebars');
grunt.loadNpmTasks('grunt-contrib-requirejs');
grunt.loadNpmTasks('grunt-contrib-watch');
//grunt.loadNpmTasks('grunt-mocha');
grunt.loadNpmTasks('grunt-contrib-less');
grunt.loadNpmTasks('grunt-contrib-copy');
// Define tasks
grunt.registerTask('test', ['jshint'/*, 'mocha'*/]);
grunt.registerTask('styles', ['less']);
grunt.registerTask('build', ['handlebars', 'test', 'requirejs', 'styles', 'version-assets']);
grunt.registerTask('deploy', ['build', 'copy']);
grunt.registerTask('default', 'deploy');
};
<!DOCTYPE html>
<html lang="en">
<head>
<title></title>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="assets/stylesheets/styles.df8eb1cc16d4b69c35ae61f5b7fcbe9c.css">
</head>
<body>
<div class="container-fluid main-app"></div>
<script src="config.js"></script>
<script>
(function () {
var methods, i;
var DEBUG = AppConfig.enableDebug || false;
if (! DEBUG) {
if (! window.console) {
window.console = {};
}
methods = ["log", "debug", "warn", "info"];
for (i = 0; i < methods.length; i++) {
console[methods[i]] = function () {};
}
}
}());
</script>
<script src="assets/javascripts/build.a81f36d51120b3dbadbb386dac55bcda.js"></script>
</body>
</html>
{
"name": "-client",
"version": "1.0.0",
"private": true,
"scripts": {
"test": "grunt build"
},
"devDependencies": {
"grunt": "0.4.5",
"grunt-contrib-copy": "0.5.0",
"grunt-contrib-jshint": "0.10.0",
"grunt-contrib-handlebars": "0.8.0",
"grunt-contrib-requirejs": "0.4.4",
"grunt-contrib-watch": "0.6.1",
"grunt-contrib-less": "0.11.0",
"node-version-assets": "0.2.0"
}
}
require.config({
baseUrl: "../src",
paths: {
// App deps
"jquery": "../bower_components/jquery/dist/jquery",
"jquery.cookie": "../bower_components/jquery.cookie/jquery.cookie",
"underscore": "../bower_components/underscore/underscore",
"backbone": "../bower_components/backbone/backbone",
//"backbone-relational": "../bower_components/backbone-relational/backbone-relational",
"backbone-subviews": "../bower_components/backbone.subviews/backbone.subviews",
"handlebars": "../bower_components/handlebars/handlebars.runtime",
"backgrid": "../bower_components/backgrid/lib/backgrid",
"moment": "../bower_components/momentjs/moment",
"showdown": "../bower_components/showdown/src/showdown",
"cryptojs.core": "../bower_components/cryptojslib/components/core",
"cryptojs.base64": "../bower_components/cryptojslib/components/enc-base64",
/*
// Dev / Test deps
"chai": "../bower_components/chai/chai",
"test": "../test",
*/
"bootstrap": "../bower_components/bootstrap/dist/js/bootstrap"
},
shim: {
handlebars: {
exports: "Handlebars",
// not sure why this is needed in AMD/require.js land but found it here
// https://github.com/gruntjs/grunt-contrib-handlebars/issues/48#issuecomment-17923555
init: function () {
this.Handlebars = Handlebars;
return this.Handlebars;
}
},
// Include bootstrap as a shim as it doesn't support AMD.
// See PR at https://github.com/twitter/bootstrap/pull/534
bootstrap: {
deps: ["jquery"]
},
backgrid: {
deps: ["backbone", "underscore", "jquery"],
exports: "Backgrid"
},
showdown: {
exports: "ShowDown"
},
"cryptojs.core": {
init: function() {
this.CryptoJS = CryptoJS;
return this.CryptoJS;
}
},
"cryptojs.base64": {
deps: ["cryptojs.core"],
exports: "CryptoJS"
}
},
urlArgs: "bust=" + (new Date()).getTime() // cache-busting for development
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment