Skip to content

Instantly share code, notes, and snippets.

@jh3y
Last active August 19, 2018 19:04
Show Gist options
  • Save jh3y/3ecafb96903e069bf640b5290ef9985a to your computer and use it in GitHub Desktop.
Save jh3y/3ecafb96903e069bf640b5290ef9985a to your computer and use it in GitHub Desktop.
serve.js
const browsersync = require('browser-sync'),
vf = require('vinyl-file'),
vss = require('vinyl-source-stream'),
vb = require('vinyl-buffer');
const start = () => {
const server = browsersync.create();
server.init({
baseDir: 'public/'
});
return server.watch('public/**', (evt, file) => {
if (evt === 'change' && file.indexOf('.css') === -1)
server.reload();
if (evt === 'change' && file.indexOf('.css') !== -1)
vf.readSync(file)
.pipe(vss(file))
.pipe(vb())
.pipe(server.stream());
});
};
@firestar300
Copy link

Nice gist ! But i have this error : vf.readSync(...).pipe is not a function

@luiscdz
Copy link

luiscdz commented Aug 19, 2018

@firestar300 Do you found any solution?

@luiscdz
Copy link

luiscdz commented Aug 19, 2018

if anybody want to use this code, you should use vinyl-file version 2.0.0, if anybody found other solution please put it here :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment