From 9cc92ccb258dd60d70bee983adbf382f0fc701c4 Mon Sep 17 00:00:00 2001 From: Matteo Pagliazzi Date: Tue, 10 Sep 2013 12:29:43 +0200 Subject: [PATCH] serve all css minimized & static files from /build --- .gitignore | 2 +- Gruntfile.js | 18 +++++++++++------- src/server.js | 1 + views/index.jade | 6 +++--- views/static/layout.jade | 6 +++--- 5 files changed, 19 insertions(+), 14 deletions(-) diff --git a/.gitignore b/.gitignore index db9a64ac62..c0f0054b81 100644 --- a/.gitignore +++ b/.gitignore @@ -7,7 +7,7 @@ config.json npm-debug.log lib public/bower_components -public/build +build src/*/*.map src/*/*/*.map diff --git a/Gruntfile.js b/Gruntfile.js index 00ecbbf19d..8858a8a5e9 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -11,7 +11,7 @@ module.exports = function(grunt) { uglify: { buildApp: { files: { - 'public/build/app.js': [ + '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', @@ -65,7 +65,7 @@ module.exports = function(grunt) { }, buildStatic: { files: { - 'public/build/static.js': [ + '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', @@ -89,8 +89,8 @@ module.exports = function(grunt) { paths: ['public'] }, files: { - 'public/build/app.css': ['public/css/index.styl'], - 'public/build/static.css': ['public/css/static.styl'] + 'build/app.css': ['public/css/index.styl'], + 'build/static.css': ['public/css/static.styl'] } } }, @@ -98,15 +98,19 @@ module.exports = function(grunt) { cssmin: { build: { files: { - 'public/build/app.css': ['public/build/app.css'], - 'public/build/static.css': ['public/build/static.css'] + 'build/app.css': ['build/app.css'], + 'build/static.css': ['build/static.css'], + 'build/bower_components/habitrpg-shared/dist/spritesheets.css': ['public/bower_components/habitrpg-shared/dist/spritesheets.css'], + 'build/bower_components/bootstrap/docs/assets/css/bootstrap.css': ['public/bower_components/bootstrap/docs/assets/css/bootstrap.css'], + 'build/bower_components/bootstrap/docs/assets/css/bootstrap-responsive.css': ['public/bower_components/bootstrap/docs/assets/css/bootstrap-responsive.css'], + 'build/bower_components/bootstrap/docs/assets/css/docs.css': ['public/bower_components/bootstrap/docs/assets/css/docs.css'] } } }, nodemon: { dev: { - ignoredFiles: ['public/*', 'Gruntfile.js', 'views/*'] // Do not work! + ignoredFiles: ['public/*', 'Gruntfile.js', 'views/*', 'build/*'] // Do not work! } }, diff --git a/src/server.js b/src/server.js index c38e877895..2ee1125bb0 100644 --- a/src/server.js +++ b/src/server.js @@ -99,6 +99,7 @@ app.use(passport.initialize()); app.use(passport.session()); app.use(app.router); +app.use(express['static'](path.join(__dirname, "/../build"))); app.use(express['static'](path.join(__dirname, "/../public"))); // development only diff --git a/views/index.jade b/views/index.jade index 0e49804f75..433e6be686 100644 --- a/views/index.jade +++ b/views/index.jade @@ -14,16 +14,16 @@ html display: none; } - // CSS + // CSS Remember to update also in Grunfile.js cssmin task! link(rel='stylesheet', href='/bower_components/bootstrap/docs/assets/css/bootstrap.css') - link(rel='stylesheet', href='/build/app.css') + link(rel='stylesheet', href='/app.css') // HabitRPG Shared link(rel='stylesheet', href='/bower_components/habitrpg-shared/dist/spritesheets.css') - if(env.NODE_ENV == 'production'){ - script(type='text/javascript', src='build/app.js') + script(type='text/javascript', src='/app.js') - }else{ // Remember to update the file list in Gruntfile.js! script(type='text/javascript', src='/bower_components/jquery/jquery.min.js') diff --git a/views/static/layout.jade b/views/static/layout.jade index f9b5ef3e8d..6c22de5eac 100644 --- a/views/static/layout.jade +++ b/views/static/layout.jade @@ -13,17 +13,17 @@ html meta(charset='utf-8') meta(name='viewport', content='width=device-width, initial-scale=1.0') - // CSS + // CSS Remember to update also in Grunfile.js cssmin task! link(rel='stylesheet', href='/bower_components/bootstrap/docs/assets/css/bootstrap.css') // Keep this out of build because the one after has some images and would like not to override it link(rel='stylesheet', href='/bower_components/bootstrap/docs/assets/css/bootstrap-responsive.css') link(href='/bower_components/bootstrap/docs/assets/css/docs.css', rel='stylesheet') - link(rel='stylesheet', href='/build/static.css') + link(rel='stylesheet', href='/static.css') // JS - if(layoutEnv.NODE_ENV == 'production'){ - script(type='text/javascript', src='/build/static.js') + script(type='text/javascript', src='/static.js') - }else{ // Remember to update the file list in Gruntfile.js! script(type='text/javascript', src='/bower_components/jquery/jquery.min.js')