diff --git a/@salix/app/index.js b/@salix/app/index.js index cb9a3f178..4d375b31f 100644 --- a/@salix/app/index.js +++ b/@salix/app/index.js @@ -1 +1 @@ -export * from './src/app' +export * from './src/app' \ No newline at end of file diff --git a/@salix/gulpfile.js b/@salix/gulpfile.js index 93746ce48..d91687647 100644 --- a/@salix/gulpfile.js +++ b/@salix/gulpfile.js @@ -1,22 +1,22 @@ -var path = require ('path'); -var gulp = require ('gulp'); +var path = require('path'); +var gulp = require('gulp'); var gutil = require('gulp-util'); var wrap = require('gulp-wrap'); -var concat = require ('gulp-concat'); -var babel = require ('gulp-babel'); -var fs = require ('fs'); -var del = require ('del'); -var webpack = require ('webpack-stream'); -var webpackConfig = require ('./webpack.config.js'); +var concat = require('gulp-concat'); +var babel = require('gulp-babel'); +var fs = require('fs'); +var del = require('del'); +var webpack = require('webpack'); +var WebpackDevServer = require("webpack-dev-server"); +var webpackConfig = require('./webpack.config.js'); // Clean var buildDir = '../services/nginx/static' -gulp.task ('clean', function () -{ - return del (buildDir +'/*', {force: true}); +gulp.task('clean', function() { + return del(buildDir +'/*', {force: true}); }); // Spliting @@ -24,83 +24,95 @@ gulp.task ('clean', function () var splitingDir = './app/src/spliting'; var splitingFiles = splitingDir +'/*'; -gulp.task ('spliting', function () -{ - var jsonDeps = fs.readFileSync (splitingDir +'/deps.json'); - var modules = JSON.parse (jsonDeps); +gulp.task('spliting', function() { + var jsonDeps = fs.readFileSync(splitingDir +'/deps.json'); + var modules = JSON.parse(jsonDeps); - var importTpl = fs.readFileSync (splitingDir +'/import.tpl.js', 'utf8'); - var requireTpl = fs.readFileSync (splitingDir +'/require.tpl.js', 'utf8'); + var importTpl = fs.readFileSync(splitingDir +'/import.tpl.js', 'utf8'); + var requireTpl = fs.readFileSync(splitingDir +'/require.tpl.js', 'utf8'); - for (var modName in modules) + for(var modName in modules) { var deps = modules[modName]; var splitFile = './'+ modName +'/src/spliting.js'; try { - fs.unlinkSync (splitFile); + fs.unlinkSync(splitFile); } - catch (e) {} + catch(e) {} - fs.appendFileSync (splitFile, importTpl); + fs.appendFileSync(splitFile, importTpl); var i = deps.length; - while (i--) - fs.appendFileSync (splitFile, - requireTpl.replace (/\$module/g, deps[i])); + while(i--) + fs.appendFileSync(splitFile, + requireTpl.replace(/\$module/g, deps[i])); } }); // Webpack -gulp.task ('webpack-watch', ['spliting'], function () -{ - webpackConfig.watch = true; - return gulp.src (['app/index.js', 'login/index.js']) - .pipe (webpack (webpackConfig)) - .pipe (gulp.dest (buildDir)); +gulp.task('webpack', ['spliting'], function(callback) { + var myDevConfig = Object.create(webpackConfig); + myDevConfig.debug = true; + + var devCompiler = webpack(myDevConfig); + + devCompiler.run(function(err, stats) { + if(err) throw new gutil.PluginError('webpack', err); + gutil.log('[webpack]', stats.toString({colors: true})); + callback(); + }); }); -gulp.task ('webpack', ['spliting'], function () -{ - return gulp.src (['app/index.js', 'login/index.js']) - .pipe (webpack (webpackConfig)) - .pipe (gulp.dest (buildDir)); +gulp.task('webpack-dev-server', ['spliting'], function() { + var myConfig = Object.create(webpackConfig); + myConfig.debug = true; + + for (var entry in myConfig.entry) + myConfig.entry[entry] + .unshift('webpack-dev-server/client?http://0.0.0.0:8081/'); + + var devServer = new WebpackDevServer(webpack(myConfig), { + publicPath: '/', + stats: {colors: true}, + contentBase: buildDir + }) + .listen(8081, '0.0.0.0', function(err) { + if(err) throw new gutil.PluginError('webpack-dev-server', err); + gutil.log('[webpack-dev-server]', 'Listening'); + }); }); // Routes var routeFiles = './crud/**/routes.js'; -gulp.task ('routes', function () -{ +gulp.task('routes', function() { var fileTpl = '\n"<%=file.relative%>": <%=contents%>'; var globalTpl = 'var routes = {<%=contents%>\n}'; - return gulp.src (routeFiles) - .pipe (wrap (fileTpl)) - .pipe (concat ('salix.routes.js', {newLine: ','})) - .pipe (wrap (globalTpl)) - .pipe (babel ({presets: ['es2015']})) - .pipe (gulp.dest (buildDir)); + return gulp.src(routeFiles) + .pipe(wrap(fileTpl)) + .pipe(concat('salix.routes.js', {newLine: ','})) + .pipe(wrap(globalTpl)) + .pipe(babel({presets: ['es2015']})) + .pipe(gulp.dest(buildDir)); }); // Watch -gulp.task ('watch', function () -{ - gulp.watch (routeFiles, ['routes']); - gulp.watch (splitingFiles, ['spliting']); +gulp.task('watch', function() { + gulp.watch(routeFiles, ['routes']); + gulp.watch(splitingFiles, ['spliting']); }); // Default -gulp.task ('build', ['clean'], function () -{ - return gulp.start ('routes', 'webpack'); +gulp.task('build', ['clean'], function() { + return gulp.start('routes', 'webpack'); }); -gulp.task ('default', ['clean'], function () -{ - return gulp.start ('watch', 'routes', 'webpack-watch'); +gulp.task('default', ['clean'], function() { + return gulp.start('watch', 'routes', 'webpack-dev-server'); }); diff --git a/@salix/package.json b/@salix/package.json index d21e546f5..d2ed1d8ae 100644 --- a/@salix/package.json +++ b/@salix/package.json @@ -39,8 +39,7 @@ "sass-loader": "^4.0.2", "style-loader": "^0.13.1", "webpack": "^1.13.3", - "webpack-dev-server": "^1.16.2", - "webpack-stream": "^3.2.0" + "webpack-dev-server": "^1.16.2" }, "scripts": { "build": "webpack --progress --colors --watch", diff --git a/@salix/webpack.config.js b/@salix/webpack.config.js index 0471ae6ed..9dfc089d0 100644 --- a/@salix/webpack.config.js +++ b/@salix/webpack.config.js @@ -45,10 +45,6 @@ var config = { 'node_modules' ] }, - devServer: { - inline: true, - host: '0.0.0.0' - }, devtool: 'source-map' }; diff --git a/env.cmd b/env.cmd index c83603280..1f97e203f 100644 --- a/env.cmd +++ b/env.cmd @@ -1,34 +1,31 @@ @echo off +set currentDir=%~dp0 +set nginxPrefix=%currentDir%\services\nginx +set nginxConf=%nginxPrefix%\conf-dev.conf + if "%1"=="" goto caseStart if "%1"=="start" goto caseStart if "%1"=="stop" goto caseStop goto caseUsage :caseStart - echo ###################### - echo "Arrancando Servicios" - echo ###################### - echo. call "%0" stop + echo "################################ Starting services" call forever start forever.json call forever list - call nginx -c conf-dev.conf + call nginx -c "%nginxConf%" -p "%nginxPrefix%" call cd @salix call gulp - goto salir + goto caseExit :caseStop - echo ###################### - echo "Parando Servicios" - echo ###################### - echo. + echo "################################ Stoping services" call forever stopall - call forever list - call nginx -c conf-dev.conf -p @salix -s stop - goto salir + call nginx -c "%nginxConf%" -p "%nginxPrefix%" -s stop + goto caseExit :caseUsage echo "Usage: %0 [start|stop]" -:salir \ No newline at end of file +:caseExit \ No newline at end of file diff --git a/env.sh b/env.sh index 7ed4d0354..6c789897d 100755 --- a/env.sh +++ b/env.sh @@ -1,19 +1,26 @@ #!/bin/bash -nginxDir="${PWD}/services/nginx" +nginxBin="/usr/sbin/nginx" +nginxPrefix="${PWD}/services/nginx" +nginxConf="$nginxPrefix/conf-dev.conf" + +if [ ! -f $nginxBin ]; then + nginxBin="nginx" +fi case "$1" in start|"") + $0 stop + echo "################################ Starting services" forever start forever.json forever list - /usr/sbin/nginx -c "$nginxDir/conf-dev.conf" -p "$nginxDir" + "$nginxBin" -c "$nginxConf" -p "$nginxPrefix" cd @salix && gulp ;; stop) + echo "################################ Stoping services" forever stopall - forever list - /usr/sbin/nginx -c "$nginxDir/conf-dev.conf" -p "$nginxDir" -s stop - cd @salix && gulp clean + "$nginxBin" -c "$nginxConf" -p "$nginxPrefix" -s stop ;; *) echo "Usage: `basename "$0"` [start|stop]" diff --git a/services/nginx/conf-dev.conf b/services/nginx/conf-dev.conf index 14e82fa8e..cf200d04a 100644 --- a/services/nginx/conf-dev.conf +++ b/services/nginx/conf-dev.conf @@ -25,9 +25,8 @@ http { server_name localhost; autoindex off; - location /static { - alias static/; - autoindex on; + location ~ ^/static(?:/(.*))?$ { + proxy_pass http://127.0.0.1:8081/$1$is_args$args; } location ~ ^/account(?:/(.*))?$ {