convert main app to browserify

This commit is contained in:
Radek Stepan 2014-10-17 20:32:48 -07:00
parent 0682bdd39b
commit dc3a871ad6
8 changed files with 540 additions and 42279 deletions

View File

@ -1,101 +1,107 @@
module.exports = (grunt) -> module.exports = (grunt) ->
grunt.initConfig grunt.initConfig
pkg: grunt.file.readJSON("package.json") pkg: grunt.file.readJSON("package.json")
apps_c: clean: [ 'public/js' ]
loader:
dest: 'public/js/commonjs.js'
commonjs: browserify:
src: [ 'src/**/*.{coffee,js,json,mustache,html}' ] commonjs:
dest: 'public/js/app.js' src: 'src/app.coffee'
options: dest: 'public/js/app.bundle.js'
main: 'src/app.coffee' options:
loader: no transform: [
# CoffeeScript.
'coffeeify'
# Mustaches.
'ractivate'
]
stylus: stylus:
compile: compile:
src: [ src: [
'src/styles/fonts.styl' 'src/styles/fonts.styl'
'src/styles/icons.styl' 'src/styles/icons.styl'
'src/styles/chart.styl' 'src/styles/chart.styl'
'src/styles/notification.styl' 'src/styles/notification.styl'
'src/styles/app.styl' 'src/styles/app.styl'
] ]
dest: 'public/css/app.css' dest: 'public/css/app.css'
concat: concat:
scripts: scripts:
src: [ src: [
# CommonJS loader. # CommonJS loader.
'public/js/commonjs.js' 'public/js/commonjs.js'
# Vendor dependencies. # Vendor dependencies.
'vendor/lodash/dist/lodash.js' 'vendor/lodash/dist/lodash.js'
'vendor/ractive/ractive.js' 'vendor/ractive/ractive.js'
'vendor/ractive-transitions-fade/ractive-transitions-fade.js' 'vendor/ractive-transitions-fade/ractive-transitions-fade.js'
'vendor/ractive-ractive/index.js' 'vendor/ractive-ractive/index.js'
'vendor/firebase/firebase.js' 'vendor/firebase/firebase.js'
'vendor/firebase-simple-login/firebase-simple-login.js' 'vendor/firebase-simple-login/firebase-simple-login.js'
'vendor/superagent/superagent.js' 'vendor/superagent/superagent.js'
'vendor/lscache/lscache.js' 'vendor/lscache/lscache.js'
'vendor/async/lib/async.js' 'vendor/async/lib/async.js'
'vendor/moment/moment.js' 'vendor/moment/moment.js'
'vendor/d3/d3.js' 'vendor/d3/d3.js'
'vendor/d3-tip/index.js' 'vendor/d3-tip/index.js'
'vendor/marked/lib/marked.js' 'vendor/marked/lib/marked.js'
'vendor/director/build/director.js' 'vendor/director/build/director.js'
# Our app. # Our app.
'public/js/app.js' 'public/js/app.js'
] ]
dest: 'public/js/app.bundle.js' dest: 'public/js/app.bundle.js'
options: options:
separator: ';' # for minification purposes separator: ';' # for minification purposes
styles: styles:
src: [ src: [
# Vendor dependencies. # Vendor dependencies.
'vendor/normalize-css/normalize.css' 'vendor/normalize-css/normalize.css'
# Our style. # Our style.
'public/css/app.css' 'public/css/app.css'
] ]
dest: 'public/css/app.bundle.css' dest: 'public/css/app.bundle.css'
uglify: uglify:
scripts: scripts:
files: files:
'public/js/app.min.js': 'public/js/app.js' 'public/js/app.min.js': 'public/js/app.js'
'public/js/app.bundle.min.js': 'public/js/app.bundle.js' 'public/js/app.bundle.min.js': 'public/js/app.bundle.js'
cssmin: cssmin:
combine: combine:
files: files:
'public/css/app.min.css': 'public/css/app.css' 'public/css/app.min.css': 'public/css/app.css'
'public/css/app.bundle.min.css': 'public/css/app.bundle.css' 'public/css/app.bundle.min.css': 'public/css/app.bundle.css'
watch: watchify:
scripts: scripts:
files: "src/**/*.*" files: "src/**/*.*"
tasks: [ "default" ] tasks: [ "default" ]
options: options:
interrupt: true # interrupt build when a file has changed? interrupt: true # interrupt build when a file has changed?
debounceDelay: 250 # delay a bit debounceDelay: 250 # delay a bit
livereload: true livereload: true
grunt.loadNpmTasks('grunt-apps-c') grunt.loadNpmTasks('grunt-browserify')
grunt.loadNpmTasks('grunt-contrib-stylus') grunt.loadNpmTasks('grunt-contrib-stylus')
grunt.loadNpmTasks('grunt-contrib-concat') grunt.loadNpmTasks('grunt-contrib-concat')
grunt.loadNpmTasks('grunt-contrib-uglify') grunt.loadNpmTasks('grunt-contrib-uglify')
grunt.loadNpmTasks('grunt-contrib-cssmin') grunt.loadNpmTasks('grunt-contrib-cssmin')
grunt.loadNpmTasks('grunt-contrib-watch') grunt.loadNpmTasks('grunt-contrib-watch')
grunt.loadNpmTasks('grunt-contrib-clean')
grunt.loadNpmTasks('grunt-watchify')
grunt.registerTask('default', [ grunt.registerTask('default', [
'apps_c' 'clean'
'stylus' 'browserify'
'concat' 'stylus'
]) #'concat'
])
grunt.registerTask('minify', [ grunt.registerTask('minify', [
'uglify' 'uglify'
'cssmin' 'cssmin'
]) ])

View File

@ -7,7 +7,7 @@ build:
watch: watch:
grunt grunt
grunt watch grunt watchify
serve: serve:
cd public; python -m SimpleHTTPServer 8000 cd public; python -m SimpleHTTPServer 8000

View File

@ -1,19 +1,23 @@
{ {
"name": "burnchart", "name": "burnchart",
"version": "0.0.0", "version": "0.0.0",
"description": "GitHub Burndown Chart as a Service", "description": "GitHub Burndown Chart as a Service",
"devDependencies": { "devDependencies": {
"grunt": "~0.4.1", "grunt": "~0.4.1",
"grunt-apps-c": "0.2.0", "grunt-contrib-stylus": "~0.9.0",
"grunt-contrib-stylus": "~0.9.0", "grunt-contrib-concat": "~0.3.0",
"grunt-contrib-concat": "~0.3.0", "grunt-contrib-uglify": "~0.2.5",
"grunt-contrib-uglify": "~0.2.5", "grunt-contrib-cssmin": "~0.6.2",
"grunt-contrib-cssmin": "~0.6.2", "grunt-contrib-watch": "~0.6.1",
"grunt-contrib-watch": "~0.6.1" "grunt-browserify": "~3.1.0",
}, "coffeeify": "~0.7.0",
"repository": { "ractivate": "~0.2.0",
"type": "git", "grunt-contrib-clean": "~0.6.0",
"url": "git://github.com/radekstepan/burnchart.io.git" "grunt-watchify": "~0.1.0"
}, },
"author": "Radek <dev@radekstepan.com>" "repository": {
"type": "git",
"url": "git://github.com/radekstepan/burnchart.io.git"
},
"author": "Radek <dev@radekstepan.com>"
} }

View File

@ -6,12 +6,6 @@
<link rel="stylesheet" type="text/css" href="css/app.bundle.css"> <link rel="stylesheet" type="text/css" href="css/app.bundle.css">
<script src="js/app.bundle.js"></script> <script src="js/app.bundle.js"></script>
<script src="http://0.0.0.0:35729/livereload.js"></script>
</head> </head>
<body> <body></body>
<script>
var app = require('burnchart');
app.render('body');
</script>
</body>
</html> </html>

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,92 +0,0 @@
(function(/*! Brunch !*/) {
'use strict';
var globals = typeof window !== 'undefined' ? window : global;
if (typeof globals.require === 'function') return;
var modules = {};
var cache = {};
var has = function(object, name) {
return ({}).hasOwnProperty.call(object, name);
};
var expand = function(root, name) {
var results = [], parts, part;
if (/^\.\.?(\/|$)/.test(name)) {
parts = [root, name].join('/').split('/');
} else {
parts = name.split('/');
}
for (var i = 0, length = parts.length; i < length; i++) {
part = parts[i];
if (part === '..') {
results.pop();
} else if (part !== '.' && part !== '') {
results.push(part);
}
}
return results.join('/');
};
var dirname = function(path) {
return path.split('/').slice(0, -1).join('/');
};
var localRequire = function(path) {
return function(name) {
var dir = dirname(path);
var absolute = expand(dir, name);
return globals.require(absolute, path);
};
};
var initModule = function(name, definition) {
var module = {id: name, exports: {}};
cache[name] = module;
definition(module.exports, localRequire(name), module);
return module.exports;
};
var require = function(name, loaderPath) {
var path = expand(name, '.');
if (loaderPath == null) loaderPath = '/';
if (has(cache, path)) return cache[path].exports;
if (has(modules, path)) return initModule(path, modules[path]);
var dirIndex = expand(path, './index');
if (has(cache, dirIndex)) return cache[dirIndex].exports;
if (has(modules, dirIndex)) return initModule(dirIndex, modules[dirIndex]);
throw new Error('Cannot find module "' + name + '" from '+ '"' + loaderPath + '"');
};
var define = function(bundle, fn) {
if (typeof bundle === 'object') {
for (var key in bundle) {
if (has(bundle, key)) {
modules[key] = bundle[key];
}
}
} else {
modules[bundle] = fn;
}
};
var list = function() {
var result = [];
for (var item in modules) {
if (has(modules, item)) {
result.push(item);
}
}
return result;
};
globals.require = require;
globals.require.define = define;
globals.require.register = define;
globals.require.list = list;
globals.require.brunch = true;
})();

View File

@ -1,20 +1,22 @@
( require "./#{key}" for key in [ # Lodash mixins.
'utils/mixins.coffee' require './utils/mixins.coffee'
'models/projects.coffee' # will load projects from localStorage # Will load projects from localStorage.
] ) require './models/projects.coffee'
Header = require './views/header.coffee' Header = require './views/header.coffee'
Notify = require './views/notify.coffee' Notify = require './views/notify.coffee'
router = require './modules/router.coffee' router = require './modules/router.coffee'
App = Ractive.extend app = new Ractive
'template': require './templates/app.html' 'template': require './templates/app.html'
'el': 'body'
'components': { Header, Notify } 'components': { Header, Notify }
onrender: -> onrender: ->
# Start the router. # Start the router.
router.init '/' router.init '/'
module.exports = new App() do app.render