From 287fd05864fd7d46f293e0bdf6dd9a8b44ba4fa0 Mon Sep 17 00:00:00 2001 From: Juan Ferrer Toribio Date: Thu, 6 Oct 2016 11:18:02 +0200 Subject: [PATCH 1/2] Concatena JSON de rutas usando Gulp --- @salix/app/src/spliting.js | 2 +- @salix/compras/routing.json | 4 ++++ @salix/ventas/routing.json | 4 ++++ gulpfile.js | 16 ++++++++++++++++ package.json | 4 +++- server.js | 0 webpack.config.js | 5 ++++- 7 files changed, 32 insertions(+), 3 deletions(-) create mode 100644 @salix/compras/routing.json create mode 100644 @salix/ventas/routing.json create mode 100644 gulpfile.js create mode 100644 server.js diff --git a/@salix/app/src/spliting.js b/@salix/app/src/spliting.js index a672cea560..d0cbc59a1b 100644 --- a/@salix/app/src/spliting.js +++ b/@salix/app/src/spliting.js @@ -17,4 +17,4 @@ const pagos = () => { require.ensure([], () => { require('@salix/pagos') }, "salix.pagos"); -}; \ No newline at end of file +}; diff --git a/@salix/compras/routing.json b/@salix/compras/routing.json new file mode 100644 index 0000000000..ac6307544f --- /dev/null +++ b/@salix/compras/routing.json @@ -0,0 +1,4 @@ +{ + "route": "buys", + "template": "buys.template" +} diff --git a/@salix/ventas/routing.json b/@salix/ventas/routing.json new file mode 100644 index 0000000000..ef776755ee --- /dev/null +++ b/@salix/ventas/routing.json @@ -0,0 +1,4 @@ +{ + "route": "sales", + "template": "sales.template" +} diff --git a/gulpfile.js b/gulpfile.js new file mode 100644 index 0000000000..6fbf8aebc2 --- /dev/null +++ b/gulpfile.js @@ -0,0 +1,16 @@ + +var gulp = require ('gulp'); +var jsoncombine = require ('gulp-jsoncombine'); + +function combineFunc (data) +{ + return new Buffer (JSON.stringify (data)); +} + +gulp.task ('default', function () +{ + var json = gulp.src ('./@salix/**/routing.json') + .pipe (jsoncombine ('salix.routes.json', combineFunc)) + .pipe (gulp.dest ('./build')); +}); + diff --git a/package.json b/package.json index 083501fea4..20e5a8c38f 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,9 @@ "babel-core": "*", "babel-preset-es2015": "*", "babel-loader": "*", - "raw-loader": "*" + "raw-loader": "*", + "gulp": "^3.9.1", + "gulp-jsoncombine": "^1.0.3" }, "scripts": { "dev": "webpack --progress --colors --watch" diff --git a/server.js b/server.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/webpack.config.js b/webpack.config.js index a14c565e95..d1693911ea 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -22,9 +22,12 @@ module.exports = query: { presets: ['es2015'] } - }, { + },{ test: /\.html$/, loader: 'raw' + },{ + test: /\.json$/, + loader: 'json' } ] }, From d94bfa0adc5d9290ae6ef2b91598a2790eba4dc1 Mon Sep 17 00:00:00 2001 From: Juan Ferrer Toribio Date: Thu, 6 Oct 2016 12:16:07 +0200 Subject: [PATCH 2/2] Servidor HTTP con express que sirve el archivo de rutas --- package.json | 1 + server.js | 24 ++++++++++++++++++++++++ webpack.config.js | 4 ++-- 3 files changed, 27 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 9478c538ec..df20f4e4b1 100644 --- a/package.json +++ b/package.json @@ -11,6 +11,7 @@ "dependencies": { "angular": "^1.5.8", "angular-ui-router": "^1.0.0-beta.3", + "express": "^4.14.0", "material-design-lite": "^1.2.1", "oclazyload": "^0.6.3" }, diff --git a/server.js b/server.js index e69de29bb2..cee4df2ea1 100644 --- a/server.js +++ b/server.js @@ -0,0 +1,24 @@ + +var express = require ('express'); + +function getRoutes (req, res) +{ + var routes = require ('./build/salix.routes.json'); + res.send (JSON.stringify (routes)); +} + +function getDefault (res, res) +{ + res.sendStatus (404); +} + +function onListen () +{ + console.log ('HTTP server started.'); +} + +var app = express (); +app.get ('/routes.json', getRoutes); +app.all (/.*/, getDefault); +app.listen (8080, onListen); + diff --git a/webpack.config.js b/webpack.config.js index 2738ae85eb..6ff905c056 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -1,6 +1,6 @@ -var webpack = require('webpack'); -var path = require('path'); +var webpack = require ('webpack'); +var path = require ('path'); module.exports = {