本文整理汇总了TypeScript中browser-sync.init函数的典型用法代码示例。如果您正苦于以下问题:TypeScript init函数的具体用法?TypeScript init怎么用?TypeScript init使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了init函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1:
let runServer = () => {
if (argv['proxy']) {
BROWSER_SYNC_CONFIG.middleware.unshift(require('http-proxy-middleware')(
['/api', '/login', '/logout', '/swagger'], { target: argv['proxy'], xfwd: true}));
}
browserSync.init(BROWSER_SYNC_CONFIG);
};
示例2: function
gulp.task('browserSync', function () {
browserSync.init({
port: 8000,
proxy: "http://localhost:12345"
});
function debounce(fn, delay) {
var timer = null;
return function () {
var context = this, args = arguments;
clearTimeout(timer);
timer = setTimeout(function () {
fn.apply(context, args);
}, delay);
};
}
gulp.watch(["src/**/*.ts"], ['compile', 'reloadBrowserSync']).on('change', function (e) {
console.log('TypeScript file ' + e.path + ' has been changed. Compiling.');
});
gulp.watch(["src/*js", "src/**/*.html", "src/**/*.css"], ['resources', 'reloadBrowserSync']).on('change', function (e) {
console.log('Resource file ' + e.path + ' has been changed. Updating.');
});
gulp.watch('src/**/*.scss', ['sass', 'resources', 'reloadBrowserSync'], function(e){
console.log('Sass file ' + e.path + ' has been changed. Updating.');
});
});
示例3:
gulp.task("server", () => {
server.start();
browserSync.init({
proxy: "localhost:" + serverPort,
port: 7000
});
});
示例4: function
gulp.task('browser-sync', ['nodemon'], function() {
browserSync.init(null, {
proxy: "http://localhost:6060",
files: ["public/**/*.*","client/**/*.*"],
browser: "google chrome",
port: 8080,
});
});
示例5:
gulp.task('serve', () => {
browserSync.init({
notify: false,
server: {
baseDir: [DIR_TMP, DIR_SRC],
middleware: [historyApiFallback()],
routes: {
'/bower_components': 'bower_components',
'/node_modules': 'node_modules'
}
}
});
gulp.watch(`${DIR_SRC}/**/*.ts`, ['ts-watch']);
gulp.watch(`${DIR_SRC}/**/*.{css,html}`, null).on('change', browserSync.reload);
});
示例6: function
gulp.task("browserSync", function () {
browserSync.init({
port: 8000,
proxy: "http://localhost:8080"
});
gulp.watch(["src/**/*.ts"], ['compile', 'reloadBrowserSync']).on('change', function (e) {
console.log('TypeScript file ' + e.path + ' has been changed. Compiling.');
});
gulp.watch(["src/*.js", "src/**/*.html", "src/**/*.css"], ['resources', 'reloadBrowserSync']).on('change', function (e) {
console.log('Resource file ' + e.path + ' has been changed. Updating.');
});
gulp.watch('src/**/*.scss', ['sass', 'resources', 'reloadBrowserSync'], function(e){
console.log('Sass file ' + e.path + ' has been changed. Updating.');
});
});
示例7: modRewrite
gulp.task('serve:browser-sync', 'init the browserSync server', ['build'], () => {
browserSync.init({
port: 3002,
logLevel: 'info',
logPrefix: 'FAR Client',
server: {
baseDir: `${PATH.dest.base}`,
middleware: [
modRewrite([
'^[^\\.]*$ /index.html [L]'
])
]
},
browser: 'google chrome'
});
});
示例8:
let runServer = () => {
let baseDir = APP_DEST;
let routes:any = {
[`${APP_BASE}${APP_DEST}`]: APP_DEST,
[`${APP_BASE}node_modules`]: 'node_modules',
};
if (APP_BASE !== '/') {
routes[`${APP_BASE}`] = APP_DEST;
baseDir = `${DIST_DIR}/empty/`;
}
browserSync.init({
middleware: [require('connect-history-api-fallback')({index: `${APP_BASE}index.html`})],
port: PORT,
startPath: APP_BASE,
server: {
baseDir: baseDir,
routes: routes
}
});
};
示例9:
let runServer = () => {
browserSync.init(BROWSER_SYNC_CONFIG);
};
示例10:
let runServer = () => {
browserSync.init(getPluginConfig('browser-sync'));
};