You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
var gulp = require('gulp');
var sass = require('gulp-sass');
var rename = require('gulp-rename');
var babel = require('babelify');
var browserify = require('browserify');
var source = require('vinyl-source-stream');
var watchify = require('watchify');
gulp.task('styles', function () {
gulp
.src('index.scss')
.pipe(sass())
.pipe(rename('app.css'))
.pipe(gulp.dest('public'));
})
gulp.task('assets', function () {
gulp
.src('assets/*')
.pipe(gulp.dest('public'));
})
function compile(watch) {
var bundle = watchify(browserify('./lib/index.js'));
function rebundle() {
bundle
.transform(babel)
.bundle()
.pipe(source('index.js'))
.pipe(rename('app.js'))
.pipe(gulp.dest('public'));
}
if (watch) {
bundle.on('update', function (){
console.log('--> Bundling...');
rebundle();
})
}
rebundle();
}
gulp.task('build', function () { return compile(); });
gulp.task('watch', function (){ return compile(true); });
Existe una solucion:
Primero instala: esto: npm install -g concurrently
Luego en tu package.json edita, copia y pega esto: "start": "concurrent \"node server.js\" \"gulp watch\" "
para terminar solo ejecuta el comando: npm start
Y listo fin del problema, saludos.
I have this gulpfile.js
var gulp = require('gulp');
var sass = require('gulp-sass');
var rename = require('gulp-rename');
var babel = require('babelify');
var browserify = require('browserify');
var source = require('vinyl-source-stream');
var watchify = require('watchify');
gulp.task('styles', function () {
gulp
.src('index.scss')
.pipe(sass())
.pipe(rename('app.css'))
.pipe(gulp.dest('public'));
})
gulp.task('assets', function () {
gulp
.src('assets/*')
.pipe(gulp.dest('public'));
})
function compile(watch) {
var bundle = watchify(browserify('./lib/index.js'));
function rebundle() {
bundle
.transform(babel)
.bundle()
.pipe(source('index.js'))
.pipe(rename('app.js'))
.pipe(gulp.dest('public'));
}
if (watch) {
bundle.on('update', function (){
console.log('--> Bundling...');
rebundle();
})
}
rebundle();
}
gulp.task('build', function () { return compile(); });
gulp.task('watch', function (){ return compile(true); });
gulp.task('default',['styles', 'assets', 'build'])
so in console I should put: npm start
but or the gulp watch runs and thats it, or only the server.js works.
how do I need to set the package.json to make it work?
I have this:
"author": "KhanterWinters", "dependencies": { "empty-element": "^1.0.0", "express": "^4.14.0", "materialize-css": "^0.97.7", "page": "^1.7.1", "pug": "^2.0.0-beta6", "yo-yo": "^1.3.0" }, "devDependencies": { "babelify": "^7.3.0", "browserify": "^13.1.0", "gulp": "^3.9.1", "gulp-rename": "^1.2.2", "gulp-sass": "^2.3.2", "vinyl-source-stream": "^1.1.0", "watchify": "^3.7.0" }, "scripts": { "build": "gulp", "start": "gulp watch|node server.js" }
The text was updated successfully, but these errors were encountered: