initial grunt support, gzip enabled

This commit is contained in:
Matteo Pagliazzi 2013-09-06 19:19:43 +02:00
parent b477b0768a
commit 7cd075d787
52 changed files with 177 additions and 64 deletions

2
.gitignore vendored
View file

@ -7,7 +7,7 @@ config.json
npm-debug.log
lib
public/bower_components
builtAssets/
public/build
src/*/*.map
src/*/*/*.map

View file

@ -1,2 +1 @@
/public/*
/assets/*
/public/*

104
Gruntfile.js Normal file
View file

@ -0,0 +1,104 @@
/*global module:false*/
module.exports = function(grunt) {
// Project configuration.
grunt.initConfig({
clean: {
build: ['public/build']
},
uglify: {
buildApp: {
files: {
'public/build/app.js': [
'public/bower_components/jquery/jquery.min.js',
'public/bower_components/bootstrap-growl/jquery.bootstrap-growl.min.js',
'public/bower_components/angular/angular.min.js',
'public/bower_components/angular-sanitize/angular-sanitize.min.js',
'public/bower_components/angular-route/angular-route.min.js',
'public/bower_components/angular-resource/angular-resource.min.js',
'public/bower_components/angular-ui/build/angular-ui.min.js',
'public/bower_components/angular-ui-utils/modules/keypress/keypress.js',
// we'll remove this once angular-bootstrap is fixed
'public/bower_components/bootstrap/docs/assets/js/bootstrap.min.js',
'public/bower_components/angular-bootstrap/ui-bootstrap.min.js',
'public/bower_components/angular-bootstrap/ui-bootstrap-tpls.min.js',
// Sortable
'public/bower_components/jquery-ui/ui/minified/jquery.ui.core.min.js',
'public/bower_components/jquery-ui/ui/minified/jquery.ui.widget.min.js',
'public/bower_components/jquery-ui/ui/minified/jquery.ui.mouse.min.js',
'public/bower_components/jquery-ui/ui/minified/jquery.ui.sortable.min.js',
// habitrpg-shared
'public/bower_components/habitrpg-shared/dist/habitrpg-shared.js',
// app
'public/js/app.js',
'public/js/services/authServices.js',
'public/js/services/notificationServices.js',
'public/js/services/sharedServices.js',
'public/js/services/userServices.js',
'public/js/services/groupServices.js',
'public/js/filters/filters.js',
'public/js/directives/directives.js',
'public/js/controllers/authCtrl.js',
'public/js/controllers/characterCtrl.js',
'public/js/controllers/menuCtrl.js',
'public/js/controllers/notificationCtrl.js',
'public/js/controllers/rootCtrl.js',
'public/js/controllers/settingsCtrl.js',
'public/js/controllers/statsCtrl.js',
'public/js/controllers/tasksCtrl.js',
'public/js/controllers/taskDetailsCtrl.js',
'public/js/controllers/filtersCtrl.js',
'public/js/controllers/userAvatarCtrl.js',
'public/js/controllers/groupsCtrl.js',
'public/js/controllers/petsCtrl.js',
'public/js/controllers/inventoryCtrl.js',
'public/js/controllers/marketCtrl.js',
'public/js/controllers/footerCtrl.js'
]
}
},
buildStatic: {
files: {
'public/build/static.js': [
'public/bower_components/jquery/jquery.min.js',
'public/bower_components/habitrpg-shared/dist/habitrpg-shared.js',
'public/bower_components/angular/angular.min.js',
'public/bower_components/bootstrap/docs/assets/js/bootstrap.min.js',
'public/js/static.js',
'public/js/services/userServices.js',
'public/js/controllers/authCtrl.js'
]
}
}
},
hashres: {
options: {
fileNameFormat: '${name}-${hash}.${ext}',
},
build: {
src: [
'public/build/app.js',
'public/build/static.js'
],
dest: 'views/i-do-not-exist.jade' // Non existing file!
}
}
});
// Register tasks.
grunt.registerTask('build', ['clean:build', 'uglify', 'hashres']);
// Load tasks
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-hashres');
grunt.loadNpmTasks('grunt-contrib-clean');
};

View file

@ -1,27 +0,0 @@
//= require app
//= require services/authServices
//= require services/notificationServices
//= require services/sharedServices
//= require services/userServices
//= require services/groupServices
//= require filters/filters
//= require directives/directives
//= require controllers/authCtrl
//= require controllers/characterCtrl
//= require controllers/menuCtrl
//= require controllers/notificationCtrl
//= require controllers/rootCtrl
//= require controllers/settingsCtrl
//= require controllers/statsCtrl
//= require controllers/tasksCtrl
//= require controllers/taskDetailsCtrl
//= require controllers/filtersCtrl
//= require controllers/userAvatarCtrl
//= require controllers/groupsCtrl
//= require controllers/petsCtrl
//= require controllers/inventoryCtrl
//= require controllers/marketCtrl
//= require controllers/footerCtrl

View file

@ -1,3 +0,0 @@
//= require static
//= require services/userServices
//= require controllers/authCtrl

View file

@ -35,7 +35,6 @@
},
"resolutions": {
"jquery": "~2.0.3",
"bootstrap": "v2.3.2",
"angular-sanitize": "1.2.0-rc.1"
"bootstrap": "v2.3.2"
}
}

View file

@ -25,7 +25,10 @@
"optimist": "~0.5.2",
"mongoose": "~3.6.18",
"stylus": "~0.37.0",
"connect-assets": "~2.5.2",
"grunt": "~0.4.1",
"grunt-contrib-uglify": "~0.2.4",
"grunt-hashres": "~0.3.2",
"grunt-contrib-clean": "~0.5.0",
"bower": "~1.2.4",
"nib": "~1.0.1",
"jade": "~0.35.0",

View file

@ -67,14 +67,15 @@ passport.use(new FacebookStrategy({
// ------------ Server Configuration ------------
app.set("port", nconf.get('PORT'));
app.use(express.logger("dev"));
app.use(express.compress());
app.set("views", __dirname + "/../views");
app.set("view engine", "jade");
app.use(express.favicon());
app.use(express.logger("dev"));
app.use(middleware.cors);
app.use(middleware.forceSSL);
app.use(express.bodyParser());
app.use(require('connect-assets')());
app.use(require('connect-assets')({src: 'public'}));
app.use(express.methodOverride());
//app.use(express.cookieParser(nconf.get('SESSION_SECRET')));
app.use(express.cookieParser());

View file

@ -20,29 +20,58 @@ html
// HabitRPG Shared
link(rel='stylesheet', href='/bower_components/habitrpg-shared/dist/spritesheets.css')
// JS
script(type='text/javascript', src='/bower_components/jquery/jquery.min.js')
script(type='text/javascript', src='/bower_components/bootstrap-growl/jquery.bootstrap-growl.min.js')
script(type='text/javascript', src='/bower_components/angular/angular.min.js')
script(type='text/javascript', src='/bower_components/angular-sanitize/angular-sanitize.min.js')
script(type='text/javascript', src='/bower_components/angular-route/angular-route.min.js')
script(type='text/javascript', src='/bower_components/angular-resource/angular-resource.min.js')
script(type='text/javascript', src='/bower_components/angular-ui/build/angular-ui.min.js')
script(type='text/javascript', src='/bower_components/angular-ui-utils/modules/keypress/keypress.js')
// we'll remove this once angular-bootstrap is fixed
script(type='text/javascript', src='/bower_components/bootstrap/docs/assets/js/bootstrap.min.js')
script(type='text/javascript', src='/bower_components/angular-bootstrap/ui-bootstrap.min.js')
script(type='text/javascript', src='/bower_components/angular-bootstrap/ui-bootstrap-tpls.min.js')
- if(env.NODE_ENV == 'production'){
script(type='text/javascript', src='build/app.js')
- }else{
// Remember to update the file list in Gruntfile.js!
script(type='text/javascript', src='bower_components/jquery/jquery.min.js')
script(type='text/javascript', src='bower_components/bootstrap-growl/jquery.bootstrap-growl.min.js')
script(type='text/javascript', src='bower_components/angular/angular.min.js')
script(type='text/javascript', src='bower_components/angular-sanitize/angular-sanitize.min.js')
script(type='text/javascript', src='bower_components/angular-route/angular-route.min.js')
script(type='text/javascript', src='bower_components/angular-resource/angular-resource.min.js')
script(type='text/javascript', src='bower_components/angular-ui/build/angular-ui.min.js')
script(type='text/javascript', src='bower_components/angular-ui-utils/modules/keypress/keypress.js')
// we'll remove this once angular-bootstrap is fixed
script(type='text/javascript', src='bower_components/bootstrap/docs/assets/js/bootstrap.min.js')
script(type='text/javascript', src='bower_components/angular-bootstrap/ui-bootstrap.min.js')
script(type='text/javascript', src='bower_components/angular-bootstrap/ui-bootstrap-tpls.min.js')
// Sortable
script(type='text/javascript', src='bower_components/jquery-ui/ui/minified/jquery.ui.core.min.js')
script(type='text/javascript', src='bower_components/jquery-ui/ui/minified/jquery.ui.widget.min.js')
script(type='text/javascript', src='bower_components/jquery-ui/ui/minified/jquery.ui.mouse.min.js')
script(type='text/javascript', src='bower_components/jquery-ui/ui/minified/jquery.ui.sortable.min.js')
// habitrpg-shared
script(type='text/javascript', src='bower_components/habitrpg-shared/dist/habitrpg-shared.js')
// app
script(type='text/javascript', src='js/app.js')
script(type='text/javascript', src='js/services/authServices.js')
script(type='text/javascript', src='js/services/notificationServices.js')
script(type='text/javascript', src='js/services/sharedServices.js')
script(type='text/javascript', src='js/services/userServices.js')
script(type='text/javascript', src='js/services/groupServices.js')
// Sortable
script(type='text/javascript', src='/bower_components/jquery-ui/ui/minified/jquery.ui.core.min.js')
script(type='text/javascript', src='/bower_components/jquery-ui/ui/minified/jquery.ui.widget.min.js')
script(type='text/javascript', src='/bower_components/jquery-ui/ui/minified/jquery.ui.mouse.min.js')
script(type='text/javascript', src='/bower_components/jquery-ui/ui/minified/jquery.ui.sortable.min.js')
script(type='text/javascript', src='js/filters/filters.js')
script(type='text/javascript', src='/bower_components/habitrpg-shared/dist/habitrpg-shared.js')
script(type='text/javascript', src='js/directives/directives.js')
!= js('appMain')
script(type='text/javascript', src='js/controllers/authCtrl.js')
script(type='text/javascript', src='js/controllers/characterCtrl.js')
script(type='text/javascript', src='js/controllers/menuCtrl.js')
script(type='text/javascript', src='js/controllers/notificationCtrl.js')
script(type='text/javascript', src='js/controllers/rootCtrl.js')
script(type='text/javascript', src='js/controllers/settingsCtrl.js')
script(type='text/javascript', src='js/controllers/statsCtrl.js')
script(type='text/javascript', src='js/controllers/tasksCtrl.js')
script(type='text/javascript', src='js/controllers/taskDetailsCtrl.js')
script(type='text/javascript', src='js/controllers/filtersCtrl.js')
script(type='text/javascript', src='js/controllers/userAvatarCtrl.js')
script(type='text/javascript', src='js/controllers/groupsCtrl.js')
script(type='text/javascript', src='js/controllers/petsCtrl.js')
script(type='text/javascript', src='js/controllers/inventoryCtrl.js')
script(type='text/javascript', src='js/controllers/marketCtrl.js')
script(type='text/javascript', src='js/controllers/footerCtrl.js')
-}
//webfonts
link(href='//fonts.googleapis.com/css?family=Lato:300,400,700,400italic,700italic', rel='stylesheet', type='text/css')

View file

@ -19,15 +19,23 @@ html
// and habitrpg-shared alone is ~700kb
// JS
script(type='text/javascript', src='/bower_components/jquery/jquery.min.js')
script(type='text/javascript', src='/bower_components/habitrpg-shared/dist/habitrpg-shared.js')
script(type='text/javascript', src='/bower_components/angular/angular.min.js')
script(type='text/javascript', src='/bower_components/bootstrap/docs/assets/js/bootstrap.min.js')
- if(env.NODE_ENV == 'production'){
script(type='text/javascript', src='build/static.js')
- }else{
// Remember to update the file list in Gruntfile.js!
script(type='text/javascript', src='bower_components/jquery/jquery.min.js')
script(type='text/javascript', src='bower_components/habitrpg-shared/dist/habitrpg-shared.js')
script(type='text/javascript', src='bower_components/angular/angular.min.js')
script(type='text/javascript', src='bower_components/bootstrap/docs/assets/js/bootstrap.min.js')
script(type='text/javascript', src='js/static.js')
script(type='text/javascript', src='js/services/userServices.js')
script(type='text/javascript', src='js/controllers/authCtrl.js')
-}
script(type='text/javascript').
$.getScript("//s7.addthis.com/js/250/addthis_widget.js#pubid=lefnire");
!= js('staticMain')
body
block content