From 706b25cfe5d16531ebc953e123043f0e896bef85 Mon Sep 17 00:00:00 2001 From: stevejamesson Date: Tue, 18 Aug 2015 16:13:02 -0400 Subject: [PATCH] browserify --- .gitignore | 3 ++- package.json | 5 ++++- public/_layouts/_footer.jade | 4 ++++ public/_layouts/main.jade | 4 +++- public/assets/js/app.js | 18 ++++++++++++++++++ public/index.jade | 12 +++++++++++- 6 files changed, 42 insertions(+), 4 deletions(-) create mode 100644 public/_layouts/_footer.jade create mode 100644 public/assets/js/app.js diff --git a/.gitignore b/.gitignore index 961f2ab..4f21c98 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,5 @@ node_modules *.log secrets.* -public/assets/fonts/* \ No newline at end of file +public/assets/fonts/* +public/assets/js/bundle.js \ No newline at end of file diff --git a/package.json b/package.json index 25e2760..13be499 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,10 @@ "scripts": { "serve": "node index.js serve", "build": "npm run copy-fonts && node index.js build", - "copy-fonts": "cp -R node_modules/font-awesome/fonts node_modules/bootstrap/fonts public/assets" + "build-js": "browserify public/assets/js/app.js -o public/assets/js/bundle.js", + "watch-js": "watchify public/assets/js/app.js -o public/assets/js/bundle.js -dv", + "copy-fonts": "cp -R node_modules/font-awesome/fonts node_modules/bootstrap/fonts public/assets", + "dev": "npm run copy-fonts && npm run build-js && npm run watch-js & npm run serve" }, "repository": { "type": "git", diff --git a/public/_layouts/_footer.jade b/public/_layouts/_footer.jade new file mode 100644 index 0000000..7fa265b --- /dev/null +++ b/public/_layouts/_footer.jade @@ -0,0 +1,4 @@ +footer + .container.text-center + hr + p: small.legal © #{ new Date().getFullYear() } #{ site.name } \ No newline at end of file diff --git a/public/_layouts/main.jade b/public/_layouts/main.jade index 817f41c..5675d0a 100644 --- a/public/_layouts/main.jade +++ b/public/_layouts/main.jade @@ -5,4 +5,6 @@ block append head block body include _navbar - block main \ No newline at end of file + block main + include _footer + script(src='/assets/js/bundle.js') \ No newline at end of file diff --git a/public/assets/js/app.js b/public/assets/js/app.js new file mode 100644 index 0000000..be579f0 --- /dev/null +++ b/public/assets/js/app.js @@ -0,0 +1,18 @@ +global.jQuery = require('jquery'); +global.$ = jQuery; +require('bootstrap'); + +var moment = require('moment'); +var _ = require('underscore'); + + +var App = {}; + +App.init = function() { + console.log('App.init() from /assets/js/bundle.js'); + console.log( 'moment is working: ', moment().format('MMMM Do YYYY, h:mm:ss a') ); +}; + +$(document).ready(function() { + App.init(); +}); \ No newline at end of file diff --git a/public/index.jade b/public/index.jade index 82460ef..5e1653d 100644 --- a/public/index.jade +++ b/public/index.jade @@ -15,9 +15,19 @@ block container - [Font Awesome](http://fortawesome.github.io/Font-Awesome/) - **Support for using external libraries in templates:** - [Moment.js](http://momentjs.com/) - - [Underscore](http://underscorejs.org/) + - [Underscore.js](http://underscorejs.org/) - Easily add your own! + ## Local Development Server + + - Copies fonts from bootstrap and font-awesome + - Watches `assets/js/app.js` for changes and recompiles to `assets/js/bundle.js` + - Serves via `harp server` + + ```shell + npm run dev + ``` + ## Build ```shell