convert main app to browserify
This commit is contained in:
parent
0682bdd39b
commit
dc3a871ad6
|
@ -2,16 +2,19 @@ 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'
|
|
||||||
|
|
||||||
|
browserify:
|
||||||
commonjs:
|
commonjs:
|
||||||
src: [ 'src/**/*.{coffee,js,json,mustache,html}' ]
|
src: 'src/app.coffee'
|
||||||
dest: 'public/js/app.js'
|
dest: 'public/js/app.bundle.js'
|
||||||
options:
|
options:
|
||||||
main: 'src/app.coffee'
|
transform: [
|
||||||
loader: no
|
# CoffeeScript.
|
||||||
|
'coffeeify'
|
||||||
|
# Mustaches.
|
||||||
|
'ractivate'
|
||||||
|
]
|
||||||
|
|
||||||
stylus:
|
stylus:
|
||||||
compile:
|
compile:
|
||||||
|
@ -72,7 +75,7 @@ module.exports = (grunt) ->
|
||||||
'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" ]
|
||||||
|
@ -82,17 +85,20 @@ module.exports = (grunt) ->
|
||||||
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'
|
||||||
|
'browserify'
|
||||||
'stylus'
|
'stylus'
|
||||||
'concat'
|
#'concat'
|
||||||
])
|
])
|
||||||
|
|
||||||
grunt.registerTask('minify', [
|
grunt.registerTask('minify', [
|
||||||
|
|
2
Makefile
2
Makefile
|
@ -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
|
||||||
|
|
|
@ -4,12 +4,16 @@
|
||||||
"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",
|
||||||
|
"ractivate": "~0.2.0",
|
||||||
|
"grunt-contrib-clean": "~0.6.0",
|
||||||
|
"grunt-watchify": "~0.1.0"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
|
|
|
@ -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>
|
40273
public/js/app.bundle.js
40273
public/js/app.bundle.js
File diff suppressed because it is too large
Load Diff
1622
public/js/app.js
1622
public/js/app.js
File diff suppressed because it is too large
Load Diff
|
@ -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;
|
|
||||||
})();
|
|
|
@ -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
|
Loading…
Reference in New Issue