当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript browser-sync.create函数代码示例

本文整理汇总了TypeScript中browser-sync.create函数的典型用法代码示例。如果您正苦于以下问题:TypeScript create函数的具体用法?TypeScript create怎么用?TypeScript create使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了create函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: browserSyncInit

function browserSyncInit(): browserSync.BrowserSyncInstance {
    var browser = browserSync.create();
    browser.init();
    console.log(browser.name);
    console.log(browserSync.name);
    return browser;
}
开发者ID:1drop,项目名称:DefinitelyTyped,代码行数:7,代码来源:browser-sync-tests.ts

示例2:

export = () => {
  let coverageFolder = Config.COVERAGE_DIR;
  let watchedFiles: string[] = [join(coverageFolder, '**')];

  // Serve files from the coverage of this project
  browserSync.create().init({
    server: {
      baseDir: './' + coverageFolder
    },
    port: Config.COVERAGE_PORT,
    files: watchedFiles
  });
};
开发者ID:fade2g,项目名称:angular2-seed,代码行数:13,代码来源:serve.coverage.watch.ts

示例3: historyApiFallback

 done => {
   browserSyncServer = browserSync.create();
   browserSyncServer.init({
     online: false,
     open: false,
     port: 9000,
     logLevel: 'silent',
     proxy: {
       target: 'localhost:3000',
       middleware: [function (req, res, next) { //TODO: historyApiFallback(), 
         res.setHeader('Access-Control-Allow-Origin', '*');
         next();
       }]
     }
   }, function (err, bs) {
     let urls = bs.options.get('urls').toJS();
     console.log(`Application Available At: ${urls.local}`);
     console.log(`BrowserSync Available At: ${urls.ui}`);
     done();
   });
 }
开发者ID:jugglingthebits,项目名称:C3,代码行数:21,代码来源:run.ts

示例4: create

import {
  BrowserSyncInstance,
  create,
} from 'browser-sync';
import { writeFileSync } from 'fs';
import { runner } from 'mocha-headless-chrome';
import { resolve } from 'path';

const uuid = (): string =>
  'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c) => {
    const r = Math.random() * 16 | 0, v = c === 'x' ? r : (r & 0x3 | 0x8);
    return v.toString(16);
  });

const browserSync = create();

browserSync.init({
  server: {
    baseDir: './',
    index: 'test/integration/index.html',
  },
  open: false,
  serveStatic: [{
    route: 'resources/rnm.jpg',
    dir: 'test/resources/rnm.jpg',
  }],
}, async (_, browser: BrowserSyncInstance) => {
  const url = browser.getOption('urls').get('local');

  const result = await runner({
    file: url,
开发者ID:vladjerca,项目名称:imgstry,代码行数:31,代码来源:index.ts

示例5: getBrowserSync

export function getBrowserSync (){
    if (bs === null){
        return bs = browserSync.create('Server');
    }
    return browserSync.get('Server');
}
开发者ID:NablaT,项目名称:FarmCity,代码行数:6,代码来源:browsersync.ts

示例6: createServer

function createServer() {
    const server = browserSync.create('zacher-home-ssr')
    server.init({
        server: path.resolve(__dirname, '..', 'build'),
        ghostMode: false,
        open: false,
    })

    // rebuild and reload on source change
    const srcWatcher = chokidar.watch(srcFolder, {
        ignoreInitial: true,
    })
    function onSourceChange(event : string) {
        return (filename : string) => {
            console.info(`[src][${event}]:`, filename.replace(srcFolder, ''))
            try {
                // use exec to run the build so it's always the latest code
                execSync(`yarn run-script ${scriptsFolder}/buildReact.ts`)
                server.reload(filename)
            } catch (e) {
                console.error(e.message)
            }
        }
    }
    srcWatcher.on('add', onSourceChange('add'))
    srcWatcher.on('change', onSourceChange('change'))

    // rebuild on script change
    const scriptsWatcher = chokidar.watch(scriptsFolder)
    function onScriptChange(fullFilename : string) {
        const filename = fullFilename.replace(scriptsFolder, '')
        const scriptsToRun = scriptFileToCommandMap[filename]
        if (!scriptsToRun) {
            return
        }

        console.info('[script][changed]:', filename)
        try {
            // use exec to run the scripts one by one
            scriptsToRun.forEach(script => execSync(`yarn run-script ${scriptsFolder + script}`))
            // finally, run a fresh build
            execSync(`yarn run-script ${scriptsFolder}/buildReact.ts`)
            server.reload(filename)
        } catch (e) {
            console.error(e.message)
        }
    }
    scriptsWatcher.on('change', onScriptChange)

    // rebuild on sprite change
    const spritesWatcher = chokidar.watch(spritesFolder)
    function onSpriteChange(fullFilename : string) {
        const filename = fullFilename.replace(spritesFolder, '')

        console.info('[sprite][changed]:', filename)
        try {
            // use exec to run the build
            execSync(`yarn run-script ${scriptsFolder}/sprites.ts`)
            execSync(`yarn run-script ${scriptsFolder}/buildReact.ts`)
            server.reload(filename)
        } catch (e) {
            console.error(e.message)
        }
    }
    spritesWatcher.on('change', onSpriteChange)
}
开发者ID:bradzacher,项目名称:zacher-home,代码行数:66,代码来源:server.ts

示例7: browserSync

browserSync(config, function (err, bs) {
    console.log(browserSync.active); // true
});

var evt = browserSync.emitter;

evt.on("init", function () {
    console.log("BrowserSync is running!");
});

browserSync(config);

var has = browserSync.has("My server");

var bs = browserSync.create();

bs.init({
    server: "./app"
});

bs.reload();

function browserSyncInit(): browserSync.BrowserSyncInstance {
    var browser = browserSync.create();
    browser.init();
    console.log(browser.name);
    console.log(browserSync.name);
    return browser;
}
var browser = browserSyncInit();
开发者ID:1drop,项目名称:DefinitelyTyped,代码行数:30,代码来源:browser-sync-tests.ts

示例8: require

import gulp from "gulp";
import cp from "child_process";
import gutil from "gulp-util";
import BrowserSync from "browser-sync";
import fs from 'fs-extra';

declare function require(path: string): any;

// import image processing tasks
require('./image_tasks');

// // import search index tasks
// require('hugo-search-index/gulp')(gulp, gutil)

const browserSync = BrowserSync.create();
const hugoBin = "hugo";
const defaultArgs = ["-v"];

/**
 * hugo: runs the hugo binary to build the hugo site.
 *  
 * depends -
 *   css : builds sass & minifies css files, placing the result in static/css/ for hugo to pick it up
 *   js  : builds javascript and bundles it with webpack, placing the bundle in static/js/ for hugo to pick it up
 *   img: the img task processes images in-place in static/images/, 
 *        so it must finish before running hugo.
 */
export const hugo = gulp.series('img', buildHugo);

function buildHugo(cb, options?) {
  const args = options ? defaultArgs.concat(options) : defaultArgs;
开发者ID:gburgett,项目名称:blog,代码行数:31,代码来源:gulpfile.ts

示例9: gulpLoadPlugins

import * as gulpHelp from 'gulp-help';
import * as util from 'gulp-util';
import * as browserSync from 'browser-sync';
import * as configuration from './tools/config';
import * as gulpLoadPlugins from 'gulp-load-plugins';

const plugins = gulpLoadPlugins({camelize: true});
const CacheBuster = require('gulp-cachebust');
const del = require('del');

global.tools = {};

global.tools.gulp = gulpHelp(gulp, {description: '', hideEmpty: true});
global.tools.plugin = plugins;
global.tools.prod = false;
global.tools.mocks = util.env.mocks;
global.tools.config = configuration.config;
global.tools.bs = browserSync.create();
global.tools.cachebust = new CacheBuster();
global.tools.del = del;
global.tools.timestamp = Math.round(Date.now()/1000);

//Register tasks from tasks folder
const tasks:string[] = readdirSync('./tools/tasks/').filter((task) => {
    //filter just ts files
    return task.indexOf('.ts') !== -1;
});

tasks.forEach((task) => {
    require('./tools/tasks/' + task);
});
开发者ID:AlexKryzh,项目名称:angular-typescript-seed,代码行数:31,代码来源:gulpfile.ts

示例10: require

import chalk = require ('chalk');
import ncp = require ('ncp');
import Promise = require ('bluebird');
var Table = require ('cli-table');

import BShandler = require ('./browser-sync-handler');
import ChromeTesterClient = require ('./tester/chrome-tester-client');
import ChromeTesterServer = require ('./tester/chrome-tester-server');
import LeenaConfiguration = require ('./config');
import LeenaContext = require ('./context/context');
import logger = require ('./logger');
import utils = require ('./utils');


// Global variables for 'browser-sync' watcher and web server
var bsWatcher : any   = browserSync.create ('Watcher');
var bsWebServer : any = browserSync.create ('Web Server');

export
function initialize (pathConfigFile : string, smtSolver : string) : void {
  // JSON object for the configuration file
  var JSONcontent;

  // Content of the configuration file
  var contentFile : string;

  // Istance of LeenaConfiguration
  var leenaConfig;

  // Array of errors that can be occurred during
  // the parsing of the 'JSONcontent', errors = 0 --> no errors during parsing
开发者ID:mmicu,项目名称:leena,代码行数:31,代码来源:init.ts


注:本文中的browser-sync.create函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。