BrowserSync injection reload - gulp

My browser tab don't reload after i save my SASS in visual studio, the compilation goes very well and the file it self http://localhost:3000/css/my-ui.css looks updated
function browserSync(done) {
browsersync.init({
server: {
baseDir: "./"
},
port: 3000,
// startPath: './index.html'
startPath: './css/my-ui.css'
});
done();
}
// BrowserSync reload
function browserSyncReload(done) {
browsersync.reload();
done();
}
// Watching the changes on files
function watchFiles() {
gulp.watch("./**/*.css", browserSyncReload);
gulp.watch("./**/*.html", browserSyncReload);
gulp.watch('./scss/',style);
}
// Defining the tasks
const vendor = gulp.series(clean);
const build = gulp.series(vendor);
const watch = gulp.series(build ,gulp.parallel(watchFiles, browserSync,style));
And then with an Chrome extension i am injecting the generated file into my website. I have to this procedure because i don't have access to the website it self. I have to do the CSS outside and in the end of the day send it to the site owner. Kind outdated but it works...
// SCSS to CSS compilator
function style(){
// 1. Define the input file (scss)
return gulp.src('./scss/*.scss')
// 2. Pass it through sass compiler with map
.pipe(sourcemaps.init())
.pipe(sass().on('error', sass.logError))
// 3. Add auto prefixes
.pipe(autoprefixer({
browserslistrc: ['last 3 versions', 'ie >= 10', '> 5%'],
cascade: false
})
)
// 4. Save the compiled CSS
.pipe(sourcemaps.write('./maps'))
.pipe(
gulp.dest('./css')
)
}
It it because it's an CSS file instead an HTML or PHP file?
Can someone help me?

Related

.jade files update html files, but browser-sync refreshes too early

I've been ponding on this for hours now, I'd love a tip to get my setup going.
Whenever I save my .jade files, the browser does not update immediately. Instead, I need to save a second time before updates are reflected in the browser: the webserver refreshes prior to completing the build-jade task. This seems weird, as I do have the 'build-jade' task as a dependency prior to refreshing.
The .html file is updated after the first save, it's just the refresh occuring too early.
Any tips are greatly appreciated.
gulp-file:
/*global require*/
"use strict";
var gulp = require('gulp'),
path = require('path'),
data = require('gulp-data'),
jade = require('gulp-jade'),
prefix = require('gulp-autoprefixer'),
sass = require('gulp-sass'),
browserSync = require('browser-sync');
/*
* Change directories here
*/
var public_dir = "dist/"
var settings = {
sass_files: "applications/**/*.sass",
jade_files: "applications/**/*.jade",
js_files: "applications/**/*.js"
};
/**
* Compile .scss files into public css directory With autoprefixer no
* need for vendor prefixes then live reload the browser.
*/
gulp.task('build-sass', function() {
gulp.src(settings.sass_files)
// gulp.src(settings.sass_files, { base: "./" })
.pipe(sass({
outputStyle: 'compressed',
onError: browserSync.notify
}))
.pipe(prefix(['last 15 versions', '> 1%', 'ie 8', 'ie 7'], { cascade: true }))
.pipe(gulp.dest(public_dir))
// .pipe(gulp.dest("."))
.pipe(browserSync.reload({ stream: true }));
});
/**
* Compile .jade files and pass in data from json file
* matching file name. index.jade - index.jade.json
*/
gulp.task('build-jade', function() {
gulp.src(settings.jade_files)
// gulp.src(settings.jade_files, { base: "./" })
.pipe(jade({ pretty: true })
.pipe(gulp.dest(public_dir));
});
/**
* Recompile .jade files and live reload the browser
*/
gulp.task('jade-rebuild', ['build-jade'], function() {
browserSync.reload();
});
/**
* Wait for jade and sass tasks, then launch the browser-sync Server
*/
gulp.task('browser-sync', ['build-sass', 'build-jade'], function() {
browserSync({
server: {baseDir: public_dir},
notify: true
});
});
/**
* Watch scss files for changes & recompile
* Watch .jade files run jade-rebuild then reload BrowserSync
*/
gulp.task('watch', function() {
// gulp.watch(settings.js_files, ['jade-rebuild']);
gulp.watch(settings.sass_files, ['build-sass']);
gulp.watch(settings.jade_files, ['jade-rebuild']);
});
/**
* Default task, running just `gulp` will compile the sass,
* compile the jekyll site, launch BrowserSync then watch
* files for changes
*/
gulp.task('default', ['browser-sync', 'watch']);
Although you do have the task in the dependancy list, you are not returning the task, so gulp doesn't actually know when it finishes, fortunately this is quite a simple thing to rectify.
I have taken a sample of your code and added return to the gulp.src() function, you need to follow this procedure with all your functions and then it will work.
Hopefully this is clear enough for you to move forward.
/**
* Compile .jade files and pass in data from json file
* matching file name. index.jade - index.jade.json
*/
gulp.task('build-jade', function() {
return gulp.src(settings.jade_files)
// gulp.src(settings.jade_files, { base: "./" })
.pipe(jade({ pretty: true })
.pipe(gulp.dest(public_dir));
});
Let me know if i can be of any additional help.

Wrong reload order when using Gulp and browserSync

So I'm trying to compile pug (jade), javascript and sass files with Gulp V4, and using browserSync to reload the browser when any of these files change. There are a lot of guides out there, but no matter which way I write the code, it just doesn't seem to get the task order right. Im using gulp.series to set the task order, but browserSync doesn't want to play ball.
Here's a print of my Gulp file:
var gulp = require('gulp'),
... etc.
var paths = {
sass: ['src/scss/**/*.scss'],
js: ['src/js/**/*.js'],
pug: ['src/**/*.pug']
};
// Shared Tasks:
//*------------------------------------*/
gulp.task('clean', function(done){
del(['dist/assets/**/*.css', 'dist/assets/**/*.map', 'dist/assets/**/*.js']);
done();
});
// App Specific Tasks:
//*------------------------------------*/
// Sass
gulp.task('build-sass', function(){
gulp.src(paths.sass)
return sass(paths.sass, {
style: 'expanded'
})
.on('error', sass.logError)
.pipe(prefix('last 2 version', '> 1%', 'ie 8', 'ie 9'))
.pipe(sourcemaps.write())
.pipe(gulp.dest('dist/assets/css'))
.pipe(cleanCSS({ advanced: false, keepSpecialComments: 0 }))
.pipe(rename({suffix: '.min'}))
.pipe(gulp.dest('dist/assets/css'));
});
// JS
gulp.task('build-js', function(done){
gulp.src(paths.js)
.pipe(concat('all.js'))
.pipe(gulp.dest('dist/assets/js'))
.pipe(rename({suffix: '.min'}))
.pipe(uglify())
.pipe(gulp.dest('dist/assets/js'))
done();
// Pug
gulp.task('build-pug', function buildHTML(done){
gulp.src(['src/**/*.pug'], {
base: 'src'
})
.pipe(pug())
.pipe(gulp.dest('./dist/'))
done();
});
// Service Tasks:
//*------------------------------------*/
// Delete the compiled views dir.
gulp.task('remove', function(done){
del(['dist/views/**/']);
done();
});
// Serve the site locally and watch for file changes
gulp.task('serve', function(done){
browserSync.init({
server: {
baseDir: './dist/',
notify: false,
open: false
}
});
// Watch & Reload Pug Files
gulp.watch([paths.pug], gulp.series('build-pug')).on('change', browserSync.reload);
// Watch & Reload Sass Files
gulp.watch([paths.sass], gulp.series('build-sass')).on('change', browserSync.reload);
});
gulp.task('default', gulp.series('clean', 'build-sass', 'build-js', 'build-pug', 'remove', 'serve', function(done){
done();
}));
And the terminal console log outputs this when starting gulp:
$ gulp
[13:09:33] Using gulpfile ~/Dropbox Aaron/Dropbox (Personal)/01_Me/01_Dev/01_My Work/*Template/gulpfile.js
[13:09:33] Starting 'default'...
[13:09:33] Starting 'clean'...
[13:09:33] Finished 'clean' after 2.64 ms
[13:09:33] Starting 'build-sass'...
[13:09:33] Finished 'build-sass' after 443 ms
[13:09:33] Starting 'build-js'...
[13:09:33] Finished 'build-js' after 4.42 ms
[13:09:33] Starting 'build-pug'...
[13:09:33] Finished 'build-pug' after 3.15 ms
[13:09:33] Starting 'remove'...
[13:09:33] Finished 'remove' after 656 μs
[13:09:33] Starting 'serve'...
[BS] Access URLs:
-------------------------------------
Local: http://localhost:3000
External: http://10.130.91.51:3000
-------------------------------------
UI: http://localhost:3001
UI External: http://10.130.91.51:3001
-------------------------------------
[BS] Serving files from: ./dist/
And this when I change a file within the watched files:
[BS] File changed: src/scss/4_elements/_elements.page.scss
[13:12:33] Starting 'build-sass'...
[13:12:34] write ./style.css
[13:12:34] Finished 'build-sass' after 366 ms
So what seems to me to be happening in this instance, the file is changing, browserSync reloads the page, and then 'build-sass' starts. Which is the wrong way round. I obviously want to build the sass, then reload the page. I have to save 2 times for the browser to refresh the code I want.
Some of the code I've used is directly from the browserSync documentation:
https://www.browsersync.io/docs/gulp#gulp-reload
This doesn't seem to work.
Your log output looks right. First it runs 'default' and then your series of tasks. Later when you modify a sass file, it starts 'build-sass'. The only problem is it doesn't reload via browserSync.reload(). So I believe the problem may be here:
gulp.watch([paths.sass], gulp.series('build-sass')).on('change', browserSync.reload);
I highly recommend
https://github.com/gulpjs/gulp/blob/4.0/docs/recipes/minimal-browsersync-setup-with-gulp4.md
that is the gulp4.0 recipe to do exactly what you are trying to do. I am using pretty much what they have there, so if you have problems getting their code to work I can help. Here is my working code:
function serve (done) {
browserSync.init({
server: {
baseDir: "./",
index: "home.html"
},
ghostMode: false
});
done();
}
function reload(done) {
browserSync.reload();
done();
}
var paths = {
styles: {
src: "./scss/*.scss",
dest: "./css"
},
scripts: {
src: "./js/*.js",
dest: "./js"
}
};
function watch() {
gulp.watch(paths.scripts.src, gulp.series(processJS, reload));
gulp.watch(paths.styles.src, gulp.series(sass2css, reload));
gulp.watch("./*.html").on("change", browserSync.reload);
}
var build = gulp.series(serve, watch);
gulp.task("sync", build);
function sass2css() {
return gulp.src("./scss/*.scss")
.pipe(cached("removing scss cached"))
// .pipe(sourcemaps.init())
.pipe(sass().on("error", sass.logError))
// .pipe(sourcemaps.write("./css/sourceMaps"))
.pipe(gulp.dest("./css"));
}
function processJS() {
return gulp.src("./js/*.js")
.pipe(sourcemaps.init())
// .pipe(concat("concat.js"))
// .pipe(gulp.dest("./concats/"))
// .pipe(rename({ suffix: ".min" }))
// .pipe(uglify())
.pipe(sourcemaps.write("./js/sourceMaps/"))
.pipe(gulp.dest("./js/maps/"));
}
Note the general use of functions instead of 'tasks' and particularly the reload(done) function. You might try simply adding that to your watch statements like
gulp.watch([paths.sass], gulp.series('build-sass', reload);
after you have added the reload function, that might be enough to fix your problem without making all the other changes as in my code. Or you might simply have to add a return statement to your 'build-sass' task so gulp knows that task has completed. Good luck.

Gulp.js - `watch` not working on `typescript` changes, but works for `html,css` changes

I am using gulp to compile my ts files in to js file. when i change the ts file alone, the watch is not updating the browser. But when i change the html or css file it working fine.
I understand that, something i am missing in my watch property here. anyone help me to find the mistake here please?
here is my code :
var gulp = require('gulp'),
gulpTypescript = require('gulp-typescript')
browserSync = require('browser-sync');
var scripts = {
in : 'app/script/ts/*.*',
dest : 'app/script/js/'
}
gulp.task('typeScript', function () {
return gulp.src( scripts.in )
.pipe( gulpTypescript() )
.pipe( gulp.dest( scripts.dest ) );
});
gulp.task('browserSync', function () {
browserSync({
server: {
baseDir: 'app'
}
})
})
gulp.task('default', ['typeScript', 'browserSync'], function () {
gulp.watch([[scripts.in], ['typeScript']], browserSync.reload);
gulp.watch( ['app/*.html', 'app/styles/*.css'], browserSync.reload);
});
The possible method signatures for gulp.watch are:
gulp.watch(glob[, opts], tasks)
gulp.watch(glob[, opts, cb])
So what you're doing here makes no sense:
gulp.watch([[scripts.in], ['typeScript']], browserSync.reload);
That means you're passing 'typeScript' as part of the glob, when it is actually a task name.
Think about what you're trying to achieve:
Whenever you change a TypeScript file in scripts.in you want your typeScript task to run, so your *.ts files get compiled to scripts.dest.
Whenever a resulting *.js file in scripts.dest is changed you want the browserSync.reload callback to be executed.
So what you actually need is two different gulp.watch statements for those two steps of your TypeScript build process:
gulp.task('default', ['typeScript', 'browserSync'], function () {
gulp.watch(scripts.in, ['typeScript']); // 1st step
gulp.watch(scripts.dest + '*.*', browserSync.reload); // 2nd step
gulp.watch( ['app/*.html', 'app/styles/*.css'], browserSync.reload);
});

gulp & bourbon #include font-face issue - Custom fonts not importing?

I am using gulp for the first time I have everything working how I would like it but an stuck on one issue. I have a custom font family in a fonts folder something like "assets/fonts/font-family/...."
The issue I am having is that normally in a static project I would normally just use bourbon's :
#include font-face("source-sans-pro", "/fonts/source-sans-pro/source-sans-pro-regular", $file-formats: eot woff2 woff);
This would then allow me to use the family in a regular font-family declaration easy peasy.
However this does not work in my current gulp project. here is the gulpfile I currently have:
var gulp = require('gulp');
var browserSync = require('browser-sync');
var sass = require('gulp-sass');
var prefix = require('gulp-autoprefixer');
var cp = require('child_process');
var messages = {
jekyllBuild: '<span style="color: grey">Running:</span> $ jekyll build'
};
/**
* Build the Jekyll Site
*/
gulp.task('jekyll-build', function (done) {
browserSync.notify(messages.jekyllBuild);
return cp.spawn('jekyll', ['build'], {stdio: 'inherit'})
.on('close', done);
});
/**
* Rebuild Jekyll & do page reload
*/
gulp.task('jekyll-rebuild', ['jekyll-build'], function () {
browserSync.reload();
});
/**
* Wait for jekyll-build, then launch the Server
*/
gulp.task('browser-sync', ['sass', 'jekyll-build'], function() {
browserSync({
server: {
baseDir: '_site'
},
notify: false
});
});
/**
* Compile files from _scss into both _site/css (for live injecting) and site (for future jekyll builds)
*/
gulp.task('sass', function () {
return gulp.src('assets/css/main.scss')
.pipe(sass({
includePaths: ['css'],
onError: browserSync.notify
}))
.pipe(prefix(['last 15 versions', '> 1%', 'ie 8', 'ie 7'], { cascade: true }))
.pipe(gulp.dest('_site/assets/css'))
.pipe(browserSync.reload({stream:true}))
.pipe(gulp.dest('assets/css'));
});
/**
* Watch scss files for changes & recompile
* Watch html/md files, run jekyll & reload BrowserSync
*/
gulp.task('watch', function () {
gulp.watch('assets/css/**', ['sass']);
gulp.watch(['index.html', '_layouts/*.html', '_includes/*.html'], ['jekyll-rebuild']);
});
/**
* Default task, running just `gulp` will compile the sass,
* compile the jekyll site, launch BrowserSync & watch files.
*/
gulp.task('default', ['browser-sync', 'watch']);
I am severely confused as to what I need to do next to get custom assets working for the bourbon include. Maybe this is because I installed bourbon in a normal fashion and gulp isn't handling bourbon? Any direction or critiques are much appreciated.
What version of gulp-sass are you using?
I had the same error on version 0.7.3, but upgrading to the current (2.0.4) version fixed this problem.

Gulp keeps throwing errors and missing modules

Hi I am working with the web starter kit angular version and am having real issues compiling the code without errors. The main problematic task is the scripts one which keeps giving me random missing modules and uglify/parse problem.
events.js:85
throw er; // Unhandled 'error' event
^
Error
at new JS_Parse_Error (C:\Users\Jensten\webkit\node_modules\gulp
-uglify\node_modules\uglify-js\lib\parse.js:196:18)
at js_error (C:\Users\Jensten\webkit\node_modules\gulp-uglify\no
de_modules\uglify-js\lib\parse.js:204:11)
at croak (C:\Users\Jensten\webkit\node_modules\gulp-uglify\node_
modules\uglify-js\lib\parse.js:679:41)
at token_error (C:\Users\Jensten\webkit\node_modules\gulp-uglify
\node_modules\uglify-js\lib\parse.js:683:9)
at expect_token (C:\Users\Jensten\webkit\node_modules\gulp-uglif
y\node_modules\uglify-js\lib\parse.js:696:9)
at expect (C:\Users\Jensten\webkit\node_modules\gulp-uglify\node
_modules\uglify-js\lib\parse.js:699:36)
at expr_list (C:\Users\Jensten\webkit\node_modules\gulp-uglify\n
ode_modules\uglify-js\lib\parse.js:1202:44)
at C:\Users\Jensten\webkit\node_modules\gulp-uglify\node_modules
\uglify-js\lib\parse.js:1217:23
at C:\Users\Jensten\webkit\node_modules\gulp-uglify\node_modules
\uglify-js\lib\parse.js:722:24
at expr_atom (C:\Users\Jensten\webkit\node_modules\gulp-uglify\n
ode_modules\uglify-js\lib\parse.js:1180:35)
C:\Users\Jensten\webkit\>gulp html
[16:47:01] Using gulpfile ~\pokerstars-webkit\gulpfile.js
[16:47:01] Starting 'html'...
[16:47:02] 'html' errored after 1.54 s
[16:47:02] TypeError: undefined is not a function
at Gulp.<anonymous> (C:\Users\Jensten\webkit\gulpfile.js:130:18)
at module.exports (C:\Users\Jensten\webkit\node_modules\gulp\nod
e_modules\orchestrator\lib\runTask.js:34:7)
at Gulp.Orchestrator._runTask (C:\Users\Jensten\webkit\node_modu
les\gulp\node_modules\orchestrator\index.js:273:3)
at Gulp.Orchestrator._runStep (C:\Users\Jensten\webkit\node_modu
les\gulp\node_modules\orchestrator\index.js:214:10)
at Gulp.Orchestrator.start (C:\Users\Jensten\webkit\node_modules
\gulp\node_modules\orchestrator\index.js:134:8)
at c:\Users\Coutolil\AppData\Roaming\npm\node_modules\gulp\bin\gulp.js:129:2
0
at process._tickCallback (node.js:355:11)
at Function.Module.runMain (module.js:503:11)
at startup (node.js:129:16)
at node.js:814:3
My gulp.js file contains the following:
/**
*
* Web Starter Kit
* Copyright 2014 Google Inc. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License
*
*/
'use strict';
// Include Gulp & Tools We'll Use
var gulp = require('gulp');
var $ = require('gulp-load-plugins')();
var del = require('del');
var runSequence = require('run-sequence');
var browserSync = require('browser-sync');
var pagespeed = require('psi');
var reload = browserSync.reload;
var AUTOPREFIXER_BROWSERS = [
'ie >= 10',
'ie_mob >= 10',
'ff >= 30',
'chrome >= 34',
'safari >= 7',
'opera >= 23',
'ios >= 7',
'android >= 4.0',
'bb >= 10'
];
// Lint JavaScript
gulp.task('jshint', function() {
return gulp.src('app/scripts/**/*.js')
.pipe(reload({stream: true, once: true}))
.pipe($.jshint())
.pipe($.jshint.reporter('jshint-stylish'))
.pipe($.if(!browserSync.active, $.jshint.reporter('fail')));
});
// Optimize Images
gulp.task('images', function() {
return gulp.src('app/assets/images/**/*')
.pipe($.cache($.imagemin({
progressive: true,
interlaced: true
})))
.pipe(gulp.dest('dist/assets/images'))
.pipe($.size({title: 'images'}));
});
// Copy All Files At The Root Level (app)
gulp.task('copy', function() {
return gulp.src(['app/*', '!app/*.html', '!app/scss', '!app/scripts'], {dot: true})
.pipe(gulp.dest('dist'))
.pipe($.size({title: 'copy'}));
});
// Copy Web Fonts To Dist
gulp.task('fonts', function() {
return gulp.src(['app/assets/fonts/**'])
.pipe(gulp.dest('dist/assets/fonts'))
.pipe($.size({title: 'fonts'}));
});
// Automatically Prefix CSS
gulp.task('styles:css', function() {
return gulp.src('app/styles/css/**/*.css')
.pipe($.changed('app/styles'))
.pipe($.autoprefixer(AUTOPREFIXER_BROWSERS))
.pipe(gulp.dest('app/styles'))
.pipe($.size({title: 'styles:css'}));
});
// Compile Sass For Style Guide Components (app/styles/components)
gulp.task('styles:scss', function() {
var path = require('path');
return gulp.src('app/scss/app.scss')
.pipe($.sass({
style: 'expanded',
precision: 10,
loadPath: ['app/scss']
}))
.on('error', console.error.bind(console))
.pipe($.autoprefixer(AUTOPREFIXER_BROWSERS))
.pipe(gulp.dest('app/assets/styles'))
.pipe(reload({stream:true}))
.pipe($.size({title: 'styles:scss'}));
});
//Watch sass
//---end Watch sass
// Output Final CSS Styles
gulp.task('styles', ['styles:scss', 'styles:css']);
// Scan Your HTML For Assets & Optimize Them
gulp.task('html', function() {
return gulp.src('app/**/*.html')
.pipe($.useref.assets({searchPath: '{.tmp,app}'}))
// Concatenate And Minify JavaScript
.pipe($.if('*.js', $.uglify({preserveComments: 'some'})))
// Remove Any Unused CSS
// commented for now as it doesn't work well with angular (ng-class for example)
/*.pipe($.if('*.css', $.uncss({
html: [
'app/index.html'
],
// CSS Selectors for UnCSS to ignore
ignore: [
'.navdrawer-container.open',
/.app-bar.open/
]
})))*/
// Concatenate And Minify Styles
.pipe($.if('*.css', $.csso()))
.pipe($.useref.restore())
.pipe($.useref())
// Update Production Style Guide Paths
.pipe($.replace('components/components.css', 'components/main.min.css'))
// Minify Any HTML
.pipe($.if('*.html', $.minifyHtml({empty: true})))
// Output Files
.pipe(gulp.dest('dist'))
.pipe($.size({title: 'html'}));
});
gulp.task('scripts', function() {
return gulp.src('app/scripts/**/*.js')
.pipe($.if('*.js', $.uglify({preserveComments: 'some'})))
.pipe($.sourcemaps.init())
.pipe($.concat('app.js'))
.pipe($.sourcemaps.write('./'))
.pipe(gulp.dest('app/assets/scripts'));
});
gulp.task('vendor', function() {
var mainBowerFiles = require('main-bower-files');
return gulp.src(mainBowerFiles(/* options */))
.pipe($.if('*.js', $.uglify({preserveComments: 'some'})))
.pipe($.sourcemaps.init())
.pipe($.concat('vendor.js'))
.pipe($.sourcemaps.write('./'))
.pipe(gulp.dest('app/assets/scripts'));
})
// Clean Output Directory
gulp.task('clean', del.bind(null, ['.tmp', 'dist']));
// Watch Files For Changes & Reload
gulp.task('serve', function() {
browserSync({
open: false,
notify: true,
server: {
baseDir: ['.tmp', 'app']
}
});
gulp.watch(['app/**/*.html'], reload);
gulp.watch(['app/scss/**/*.scss'], ['styles:scss']);
// gulp.watch(['{.tmp,app}/assets/styles/**/*.css'], ['styles:css']);
gulp.watch(['app/scripts/**/*.js'], [/*'jshint',*/ 'scripts', reload]);
gulp.watch(['app/assets/images/**/*'], reload);
});
// Build and serve the output from the dist build
gulp.task('serve:dist', ['default'], function() {
browserSync({
open: false,
notify: true,
server: {
baseDir: 'dist'
}
});
});
// Build Production Files, the Default Task
gulp.task('default', ['clean'], function(cb) {
runSequence('styles', 'vendor', 'scripts', ['jshint', 'html', 'images', 'fonts', 'copy'], cb);
});
// Run PageSpeed Insights
// Update `url` below to the public URL for your site
gulp.task('pagespeed', pagespeed.bind(null, {
// By default, we use the PageSpeed Insights
// free (no API key) tier. You can use a Google
// Developer API key if you have one. See
// http://goo.gl/RkN0vE for info key: 'YOUR_API_KEY'
url: 'https://example.com',
strategy: 'mobile'
}));
// Load custom tasks from the `tasks` directory
try {
require('require-dir')('tasks');
} catch(err) {
}
I am happy to use a different file, all I want is to make sure that: Angular, SASS, compression, and file output to the assets directory are working. I am currently able to run the project but the default task obviously does not run on gulp serve, hence why I was unable to see any errors before.
Could anyone point me in the right direction?
I had the same problem just now,then i realized that I haven't added the relative Plug-in to gulp. After I add it,then it's solved!
maybe this is the solution.
Place your devDependencies at correct place in package.json file as shown below
{
"name": "my-project",
"private": true,
"devDependencies": {
//dependencies are place here
},
"engines": {
"node": ">=0.10.0"
}
}