From 9b0abab4fe539a5cb9c02abf19ac696dc87f06fd Mon Sep 17 00:00:00 2001 From: mrtone Date: Mon, 6 Jan 2014 15:42:28 +0800 Subject: [PATCH 1/3] readme --- README.md | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index d612474..df2701b 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,16 @@ enen ==== -博客(待编辑) +运行 + + npm install && bower install + +配置以下文件 + + app/server/config.js + +运行 + + npm start + +享受它吧! \ No newline at end of file From 9cd044d251f21edb4187f6c77d9e6c1620717e6c Mon Sep 17 00:00:00 2001 From: mrtone Date: Mon, 6 Jan 2014 16:10:02 +0800 Subject: [PATCH 2/3] add production guide for readme --- README.md | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index df2701b..c7fb435 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,11 @@ enen ==== -运行 +安装开发环境依赖 + + npm install -g grunt-cli bower + +安装nodejs依赖和bower依赖 npm install && bower install @@ -13,4 +17,13 @@ enen npm start -享受它吧! \ No newline at end of file +享受它吧! + + +生产环境部署 + +修改`NODE_ENV`为`production` + +运行`grunt`构建js和css + +启动项目 \ No newline at end of file From 6031891c919629f3d6f54b7219ac8866aa41d4d2 Mon Sep 17 00:00:00 2001 From: mrtone Date: Mon, 6 Jan 2014 16:38:11 +0800 Subject: [PATCH 3/3] fixed gruntfile --- .gitignore | 1 + Gruntfile.js | 31 ++++++++++++++----------------- app/public/index.css | 1 - app/public/index.js | 3 --- app/public/require.js | 1 - app/server/server.js | 2 ++ 6 files changed, 17 insertions(+), 22 deletions(-) delete mode 100644 app/public/index.css delete mode 100644 app/public/index.js delete mode 100644 app/public/require.js diff --git a/.gitignore b/.gitignore index ac5873d..13c04ae 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ node_modules/ bower_components/ +app/dist app/server/config.js \ No newline at end of file diff --git a/Gruntfile.js b/Gruntfile.js index 1bb72fa..38baaa6 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -15,7 +15,7 @@ module.exports = function( grunt ) { } ); var apps = fs.readdirSync( 'app/client' ).filter( function( x ){ - return x !== 'config.js' + return fs.statSync( 'app/client/' + x ).isDirectory( ); } ); var config = { @@ -36,14 +36,7 @@ module.exports = function( grunt ) { var requirejsTask = {}, uglifyTask = {}, lessTask = {}, - cssminTask = {}, - cleanTask = {}; - - - cleanTask.files = apps.map( function( x ){ - return 'app/public/' + x + '.*' - } ); - cleanTask.files.push( 'app/public/require.js' ); + cssminTask = {}; apps.forEach( function( x ){ @@ -53,27 +46,27 @@ module.exports = function( grunt ) { baseUrl: './', name: 'app/client/' + x + '/main', mainConfigFile: 'app/client/config.js', - out: 'app/public/' + x + '.js', + out: 'app/dist/' + x + '.js', optimize: 'none' } }; uglifyTask[ x ] = { - src: 'app/public/' + x + '.js', - dest: 'app/public/' + x + '.js' + src: 'app/dist/' + x + '.js', + dest: 'app/dist/' + x + '.js' }; lessTask[ x ] = { src: 'app/client/' + x + '/main.less', - dest: 'app/public/' + x + '.css' + dest: 'app/dist/' + x + '.css' }; cssminTask[ x ] = { - src: 'app/public/' + x + '.css', - dest: 'app/public/' + x + '.css' + src: 'app/dist/' + x + '.css', + dest: 'app/dist/' + x + '.css' }; } ); @@ -81,14 +74,18 @@ module.exports = function( grunt ) { uglifyTask.requirejs = { src: 'bower_components/requirejs/require.js', - dest: 'app/public/require.js' + dest: 'app/dist/require.js' }; grunt.initConfig( { - clean: cleanTask, + clean: { + files: [ + 'app/dist' + ] + }, requirejs: requirejsTask, uglify: uglifyTask, less: lessTask, diff --git a/app/public/index.css b/app/public/index.css deleted file mode 100644 index 0c58a66..0000000 --- a/app/public/index.css +++ /dev/null @@ -1 +0,0 @@ -body{background:#000} \ No newline at end of file diff --git a/app/public/index.js b/app/public/index.js deleted file mode 100644 index 3d67609..0000000 --- a/app/public/index.js +++ /dev/null @@ -1,3 +0,0 @@ -!function(a,b){function c(a){var b=a.length,c=fb.type(a);return fb.isWindow(a)?!1:1===a.nodeType&&b?!0:"array"===c||"function"!==c&&(0===b||"number"==typeof b&&b>0&&b-1 in a)}function d(a){var b=ob[a]={};return fb.each(a.match(hb)||[],function(a,c){b[c]=!0}),b}function e(){Object.defineProperty(this.cache={},0,{get:function(){return{}}}),this.expando=fb.expando+Math.random()}function f(a,c,d){var e;if(d===b&&1===a.nodeType)if(e="data-"+c.replace(sb,"-$1").toLowerCase(),d=a.getAttribute(e),"string"==typeof d){try{d="true"===d?!0:"false"===d?!1:"null"===d?null:+d+""===d?+d:rb.test(d)?JSON.parse(d):d}catch(f){}pb.set(a,c,d)}else d=b;return d}function g(){return!0}function h(){return!1}function i(){try{return T.activeElement}catch(a){}}function j(a,b){for(;(a=a[b])&&1!==a.nodeType;);return a}function k(a,b,c){if(fb.isFunction(b))return fb.grep(a,function(a,d){return!!b.call(a,d,a)!==c});if(b.nodeType)return fb.grep(a,function(a){return a===b!==c});if("string"==typeof b){if(Cb.test(b))return fb.filter(b,a,c);b=fb.filter(b,a)}return fb.grep(a,function(a){return bb.call(b,a)>=0!==c})}function l(a,b){return fb.nodeName(a,"table")&&fb.nodeName(1===b.nodeType?b:b.firstChild,"tr")?a.getElementsByTagName("tbody")[0]||a.appendChild(a.ownerDocument.createElement("tbody")):a}function m(a){return a.type=(null!==a.getAttribute("type"))+"/"+a.type,a}function n(a){var b=Nb.exec(a.type);return b?a.type=b[1]:a.removeAttribute("type"),a}function o(a,b){for(var c=a.length,d=0;c>d;d++)qb.set(a[d],"globalEval",!b||qb.get(b[d],"globalEval"))}function p(a,b){var c,d,e,f,g,h,i,j;if(1===b.nodeType){if(qb.hasData(a)&&(f=qb.access(a),g=qb.set(b,f),j=f.events)){delete g.handle,g.events={};for(e in j)for(c=0,d=j[e].length;d>c;c++)fb.event.add(b,e,j[e][c])}pb.hasData(a)&&(h=pb.access(a),i=fb.extend({},h),pb.set(b,i))}}function q(a,c){var d=a.getElementsByTagName?a.getElementsByTagName(c||"*"):a.querySelectorAll?a.querySelectorAll(c||"*"):[];return c===b||c&&fb.nodeName(a,c)?fb.merge([a],d):d}function r(a,b){var c=b.nodeName.toLowerCase();"input"===c&&Kb.test(a.type)?b.checked=a.checked:("input"===c||"textarea"===c)&&(b.defaultValue=a.defaultValue)}function s(a,b){if(b in a)return b;for(var c=b.charAt(0).toUpperCase()+b.slice(1),d=b,e=_b.length;e--;)if(b=_b[e]+c,b in a)return b;return d}function t(a,b){return a=b||a,"none"===fb.css(a,"display")||!fb.contains(a.ownerDocument,a)}function u(b){return a.getComputedStyle(b,null)}function v(a,b){for(var c,d,e,f=[],g=0,h=a.length;h>g;g++)d=a[g],d.style&&(f[g]=qb.get(d,"olddisplay"),c=d.style.display,b?(f[g]||"none"!==c||(d.style.display=""),""===d.style.display&&t(d)&&(f[g]=qb.access(d,"olddisplay",z(d.nodeName)))):f[g]||(e=t(d),(c&&"none"!==c||!e)&&qb.set(d,"olddisplay",e?c:fb.css(d,"display"))));for(g=0;h>g;g++)d=a[g],d.style&&(b&&"none"!==d.style.display&&""!==d.style.display||(d.style.display=b?f[g]||"":"none"));return a}function w(a,b,c){var d=Ub.exec(b);return d?Math.max(0,d[1]-(c||0))+(d[2]||"px"):b}function x(a,b,c,d,e){for(var f=c===(d?"border":"content")?4:"width"===b?1:0,g=0;4>f;f+=2)"margin"===c&&(g+=fb.css(a,c+$b[f],!0,e)),d?("content"===c&&(g-=fb.css(a,"padding"+$b[f],!0,e)),"margin"!==c&&(g-=fb.css(a,"border"+$b[f]+"Width",!0,e))):(g+=fb.css(a,"padding"+$b[f],!0,e),"padding"!==c&&(g+=fb.css(a,"border"+$b[f]+"Width",!0,e)));return g}function y(a,b,c){var d=!0,e="width"===b?a.offsetWidth:a.offsetHeight,f=u(a),g=fb.support.boxSizing&&"border-box"===fb.css(a,"boxSizing",!1,f);if(0>=e||null==e){if(e=Qb(a,b,f),(0>e||null==e)&&(e=a.style[b]),Vb.test(e))return e;d=g&&(fb.support.boxSizingReliable||e===a.style[b]),e=parseFloat(e)||0}return e+x(a,b,c||(g?"border":"content"),d,f)+"px"}function z(a){var b=T,c=Xb[a];return c||(c=A(a,b),"none"!==c&&c||(Rb=(Rb||fb("