Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
/* eslint-disable unicorn/no-process-exit */
process.exit(0)
}
const server = connect()
server.use(livereload())
server.use(serveStatic(cwd, {
index: entry
}))
port = port || 4000
server.listen(port)
lrserver.createServer({
exclusions: ['node_modules/']
}).watch(cwd)
if (openInBrowser) {
open(`http://localhost:${port}`)
}
const msg =
`\n > Serving ${chalk.green(cwd)} now.
> Entry File ${chalk.green(entry)}
> Listening at ${chalk.green(`http://localhost:${port}`)}\n`
console.log(msg)
return server
}
function buildDev() {
// cleanDist();
// start preview server
const serverConfig = previewServer();
// reload the page on any file changes in the dist folder
const livereload = require('livereload');
const lrserver = livereload.createServer({
// exts: ['html'],
});
lrserver.watch(config.buildPath);
// build js/css in watch mode
getWebpackConfig(webpackConfigCodeDev).then(configs => {
webpack(configs).watch({
ignored: ['**/*.hbs', 'node_modules']
}, (err, stats) => {
if (err) {
return console.log(err);
}
displayWebpackStats(stats, true);
console.log('webpack code done!');
console.log();
// Build CSS
const cssSource = './src/styles';
const cssBuild = './dist';
const inputCSSPath = `${cssSource}/app.sass`;
const outputCSSPath = `${cssBuild}/app.css`;
buildCSS(inputCSSPath, inputCSSPath, outputCSSPath, isBuild);
if (isBuild) return;
// Watch
watch(jsSource, (filename) => buildJS(filename, inputJSPath, outputJSPath))
watch(cssSource, (filename) => buildCSS(filename, inputCSSPath, outputCSSPath))
// Livereload
const server = livereload.createServer();
server
.watch([outputJSPath, outputCSSPath])
.on('change', (filename) => {
console.log(`Reloaded: ${filename}`)
});;
import livereload from 'livereload';
const lr = livereload.createServer();
// Trigger livereload
export default function refresh() {
lr.refresh('');
}
module.exports = function (opts) {
var server = livereload.createServer({
exts: ['scss', 'html']
});
let pth = path.join(__dirname, '..', 'exercises', opts.exercise, '**/*');
server.watch(pth);
let app = express();
let sassMw = sassMiddleware({
/* Options */
src: path.join(__dirname, '..', 'exercises', opts.exercise, 'src', 'sass'),
dest: path.join(__dirname, '..', 'exercises', opts.exercise, 'public'),
outputStyle: 'expanded'
});
// Note: you must place sass-middleware *before* `express.static` or else it will
// not work.
console.log("Request cookies: %j", req.cookies);
console.log("Request originalUrl: %j", req.originalUrl);
console.log("Request path: %j", req.path);
console.log("Request query: %j", req.query);
res.send('Received the callback');
});
app.use('/', express.static(__dirname + '/src'));
app.use('/public', express.static(__dirname + '/src'));
app.use('/protected', express.static(__dirname + '/src'));
app.use('/colin', express.static(__dirname + '/src'));
app.use('/auth/callback', express.static(__dirname + '/src'));
app.listen(3000);
console.log('Listening on port 3000.');
app = livereload.createServer({
exts: ['html', 'css', 'js', 'png', 'gif', 'jpg', 'ts']
});
app.watch(__dirname + '/src');
console.log('Live reload enabled');
const connect = require('connect');
const serveStatic = require('serve-static');
const path = require('path');
const server = connect();
server.use(serveStatic(path.resolve(__dirname, '../')));
server.listen(3000);
const livereload = require('livereload');
const lrserver = livereload.createServer();
lrserver.watch([ path.resolve(__dirname, '../demo'), path.resolve(__dirname, '../lib/index.dev.js') ]);
function closeServerOnTermination(server) {
const terminationSignals = [ 'SIGINT', 'SIGTERM' ];
terminationSignals.forEach(signal => {
process.on(signal, () => {
server.close();
process.exit();
});
});
}
closeServerOnTermination(lrserver);
require("livereload")
.createServer({
port: require("../config.json").port.livereload
})
.watch([".tmp/main.css", "src/dev/index.dev.html"]);
getPort(port + 1, (error, otherPort) => {
if (error) {
return next(error);
}
const liveReloadServer = livereload.createServer({
port: otherPort
});
const refresher = () => liveReloadServer.refresh('/');
next(null, { refresher, port: otherPort });
});
} else {
gulp.task('watch:serve', false, ['watch:serve:server'], function() {
var server = livereload.createServer({
interval: 300
});
server.watch(__dirname + '/demo');
});