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

View File

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

View File

@ -1,19 +1,23 @@
{
"name": "burnchart",
"version": "0.0.0",
"description": "GitHub Burndown Chart as a Service",
"devDependencies": {
"grunt": "~0.4.1",
"grunt-apps-c": "0.2.0",
"grunt-contrib-stylus": "~0.9.0",
"grunt-contrib-concat": "~0.3.0",
"grunt-contrib-uglify": "~0.2.5",
"grunt-contrib-cssmin": "~0.6.2",
"grunt-contrib-watch": "~0.6.1"
},
"repository": {
"type": "git",
"url": "git://github.com/radekstepan/burnchart.io.git"
},
"author": "Radek <dev@radekstepan.com>"
"name": "burnchart",
"version": "0.0.0",
"description": "GitHub Burndown Chart as a Service",
"devDependencies": {
"grunt": "~0.4.1",
"grunt-contrib-stylus": "~0.9.0",
"grunt-contrib-concat": "~0.3.0",
"grunt-contrib-uglify": "~0.2.5",
"grunt-contrib-cssmin": "~0.6.2",
"grunt-contrib-watch": "~0.6.1",
"grunt-browserify": "~3.1.0",
"coffeeify": "~0.7.0",
"ractivate": "~0.2.0",
"grunt-contrib-clean": "~0.6.0",
"grunt-watchify": "~0.1.0"
},
"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">
<script src="js/app.bundle.js"></script>
<script src="http://0.0.0.0:35729/livereload.js"></script>
</head>
<body>
<script>
var app = require('burnchart');
app.render('body');
</script>
</body>
<body></body>
</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 [
'utils/mixins.coffee'
'models/projects.coffee' # will load projects from localStorage
] )
# Lodash mixins.
require './utils/mixins.coffee'
# Will load projects from localStorage.
require './models/projects.coffee'
Header = require './views/header.coffee'
Notify = require './views/notify.coffee'
router = require './modules/router.coffee'
App = Ractive.extend
app = new Ractive
'template': require './templates/app.html'
'el': 'body'
'components': { Header, Notify }
onrender: ->
# Start the router.
router.init '/'
module.exports = new App()
do app.render