當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript tiny-lr類代碼示例

本文整理匯總了TypeScript中tiny-lr的典型用法代碼示例。如果您正苦於以下問題:TypeScript tiny-lr類的具體用法?TypeScript tiny-lr怎麽用?TypeScript tiny-lr使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了tiny-lr類的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: serveSPA

import * as connectLivereload from 'connect-livereload';
import * as express from 'express';
import * as tinylrFn from 'tiny-lr';
import * as openResource from 'open';
import * as serveStatic from 'serve-static';
import {resolve} from 'path';
import {APP_BASE, APP_DEST, LIVE_RELOAD_PORT, PORT} from '../config';

let tinylr = tinylrFn();


export function serveSPA() {
  let server = express();
  tinylr.listen(LIVE_RELOAD_PORT);

  server.use(
    APP_BASE,
    connectLivereload({ port: LIVE_RELOAD_PORT }),
    express.static(process.cwd())
  );

  server.listen(PORT, () =>
    openResource('http://localhost:' + PORT + APP_BASE + APP_DEST)
  );
}

export function notifyLiveReload(e) {
  let fileName = e.path;
  tinylr.changed({
    body: { files: [fileName] }
  });
開發者ID:jtborst,項目名稱:instaMoneyDashboard,代碼行數:31,代碼來源:server.ts

示例2: notifyLiveReload

import * as tslintStylish from 'gulp-tslint-stylish';
import * as shell from 'gulp-shell';
import * as nodemon from 'gulp-nodemon';
import {Server} from 'karma';
import * as ts from 'gulp-typescript';
import * as sourcemaps from 'gulp-sourcemaps';
import * as tinylrFn from 'tiny-lr';

import {PATH, LIVE_RELOAD_PORT, APP_BASE, APP_VERSION, DEPS_SRC} from './tools/config';

export const templateLocals = {
  APP_VERSION,
  APP_BASE
};

const tinylr = tinylrFn();

export function notifyLiveReload(changedFiles: string[]) {
  tinylr.changed({
    body: { files: changedFiles }
  });
}

const tsProject = ts.createProject('tsconfig.json');

function compileTs(src: string | string[], dest: string, inlineTpl?: boolean): NodeJS.ReadWriteStream {

  let result = gulp.src(src)
    .pipe(plumber())
    .pipe(sourcemaps.init());
開發者ID:kgeorgieva,項目名稱:kristina-georgieva-angular2-site,代碼行數:30,代碼來源:gulpfile.ts

示例3: notifyLiveReload

import * as gulp from 'gulp';
import {join} from 'path';
import * as inject from 'gulp-inject';
import * as template from 'gulp-template';
import * as tinylrFn from 'tiny-lr';

import {PATH, APP_BASE, APP_VERSION, LIVE_RELOAD_PORT} from './config';

export const tinylr = tinylrFn();

export function notifyLiveReload(changedFiles: string[]) {
  tinylr.changed({
    body: { files: changedFiles }
  });
}

export function buildInjectable(paths: string[], newBaseDir?: string, newExt?: string): NodeJS.ReadWriteStream {
  const rws = gulp.src(
    paths
      .filter(path => !/(\.map)$/.test(path), { read: false })
  );
  return rws;
}

export function transformPath(filepath: string, newBaseDir: string) {
  const namePos = filepath.lastIndexOf('/') + 1;
  const filename = filepath.substring(namePos);
  filepath = newBaseDir === '' ? filename : newBaseDir + '/' + filename;
  return filepath;
}
開發者ID:australdev,項目名稱:app,代碼行數:30,代碼來源:tasks-tools.ts

示例4: tinylr

 }).once('start', () => {
   const tinylrObj = tinylr();
   tinylrObj.listen(LIVE_RELOAD_PORT);
   const intervalId = setInterval(() => {
     const existsDist = fse.existsSync(PATHS.dest.dist.appBundle);
     if (existsDist) {
       clearInterval(intervalId);
       setTimeout(() => {
         openResource(`http://localhost:${PORT}`);
         done();
       }, 3000);
     }
   }, 500);
 })
開發者ID:brunkb,項目名稱:a2-contact,代碼行數:14,代碼來源:gulpfile.ts

示例5: createLiveReloadServer

export function createLiveReloadServer(config: ServeConfig) {
  const liveReloadServer = tinylr();
  liveReloadServer.listen(config.liveReloadPort, config.host);

  function fileChange(changedFiles: ChangedFile[]) {
    // only do a live reload if there are no diagnostics
    // the notification server takes care of showing diagnostics
    if (!hasDiagnostics(config.buildDir)) {
      liveReloadServer.changed({
        body: {
          files: changedFiles.map(changedFile => '/' + path.relative(config.wwwDir, changedFile.filePath))
        }
      });
    }
  }

  events.on(events.EventType.FileChange, fileChange);

  events.on(events.EventType.ReloadApp, () => {
    fileChange([{ event: 'change', ext: '.html', filePath: 'index.html'}]);
  });
}
開發者ID:Kode-Kitchen,項目名稱:ionic-app-scripts,代碼行數:22,代碼來源:live-reload.ts


注:本文中的tiny-lr類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。