Scripts de arranque, entorno desarrollo optimizado
This commit is contained in:
parent
e62fc745d4
commit
f260a45499
|
@ -1 +1 @@
|
|||
export * from './src/app'
|
||||
export * from './src/app'
|
|
@ -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');
|
||||
});
|
||||
|
|
|
@ -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",
|
||||
|
|
|
@ -45,10 +45,6 @@ var config = {
|
|||
'node_modules'
|
||||
]
|
||||
},
|
||||
devServer: {
|
||||
inline: true,
|
||||
host: '0.0.0.0'
|
||||
},
|
||||
devtool: 'source-map'
|
||||
};
|
||||
|
||||
|
|
25
env.cmd
25
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
|
||||
:caseExit
|
17
env.sh
17
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]"
|
||||
|
|
|
@ -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(?:/(.*))?$ {
|
||||
|
|
Loading…
Reference in New Issue