Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function server (done) {
browserSync.init({
server: PATHS.dist, port: PORT, open: false
}, done)
}
// Reload the browser with Browsersync
import browserSync from 'browser-sync'
import historyApiFallback from 'connect-history-api-fallback'
import { OUTPUT_DIR, } from './BuildConfig'
browserSync.init({
port: 3000,
ui: { port: 3001, },
server: {
baseDir: [ OUTPUT_DIR, ],
},
files: [ 'src/*.html', ],
middleware: [
historyApiFallback(),
],
})
gulp.task('browser-sync', ['nodemon', 'watch'], function () {
browserSync.init(null, {
proxy: "http://localhost:3000",
files: ["public/**/*.*", "views/**/*.*"],
port: 7000,
});
});
gulp.task('bs:init', function () {
browserSync.init({
server: {
baseDir: 'example',
routes: {
'/dist': 'dist',
'/node_modules': 'node_modules'
}
}
});
});
function serve(done) {
browserSync.init({
open: false,
notify: false,
server: 'docs',
});
done();
}
var server = {
baseDir: baseDir,
routes: routes
};
/*
* You can add a proxy to your backend by uncommenting the line below.
* You just have to configure a context which will we redirected and the target url.
* Example: $http.get('/users') requests will be automatically proxified.
*
* For more details and option, https://github.com/chimurai/http-proxy-middleware/blob/v0.9.0/README.md
*/
server.middleware = proxyMiddleware('/', {target: 'http://localhost:8080', changeOrigin: true});
browserSync.instance = browserSync.init({
startPath: '/',
server: server,
browser: browser
});
}
gulp.task('serve', ['build'], function () {
browserSync.init(null, {
proxy: "http://localhost:5000",
});
watchStyles();
watchScripts();
gulp.watch([
'./Views/**/*.cshtml',
'./wwwroot/js/**/*.min.js',
'./wwwroot/css/**/*.min.css'
]).on('change', browserSync.reload);
});
gulp.task('browserSync', function() {
const DEFAULT_FILE = 'index.html';
const ASSET_EXTENSION_REGEX = new RegExp(`\\b(?!\\?)\\.(${config.assetExtensions.join('|')})\\b(?!\\.)`, 'i');
browserSync.init({
server: {
baseDir: config.buildDir,
middleware: function(req, res, next) {
const fileHref = url.parse(req.url).href;
if ( !ASSET_EXTENSION_REGEX.test(fileHref)) {
req.url = '/' + DEFAULT_FILE;
}
return next();
}
},
port: config.browserPort,
ui: {
port: config.UIPort
},