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


TypeScript connect-livereload類代碼示例

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


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

示例1: resolve

import * as connectLivereload from 'connect-livereload';
import * as express from 'express';
import * as bodyParser from 'body-parser';
import * as openResource from 'open';
import {resolve} from 'path';

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

const INDEX_DEST_PATH = resolve(PATH.cwd, PATH.dest.app.base, 'index.html');

const server = express();

server.use(
  APP_BASE,
  connectLivereload({ port: LIVE_RELOAD_PORT })
);

server.use(express.static(PATH.dest.app.base));

server.use(bodyParser.json());
server.use(bodyParser.urlencoded({ extended: false }));

server.get('/api/**', (req, res, next) => {
  // TODO: remove this. It just mimics a delay in the backend.
  const delay = Math.floor((Math.random() * 300) + 1);
  setTimeout(() => next(), delay);
});

server.get(APP_BASE + '*', (req, res) =>
  res.sendFile(INDEX_DEST_PATH)
);
開發者ID:kgeorgieva,項目名稱:kristina-georgieva-angular2-site,代碼行數:31,代碼來源:bootstrap.ts

示例2: connect

/// <reference path="./connect-livereload.d.ts" />

import * as connect from "connect";
import * as livereload from "connect-livereload";

const app = connect();

// With no options
app.use(livereload());

// With string options
app.use(livereload({
	port: 35729,
	ignore: [".js", ".svg"]
}));

// With RegExp options
app.use(livereload({
	port: 35729,
	ignore: [/\.js(\?.*)?$/, /\.css(\?.*)?$/]
}));

// With default options
app.use(livereload({
	ignore: [
		/\.js(\?.*)?$/, /\.css(\?.*)?$/, /\.svg(\?.*)?$/, /\.ico(\?.*)?$/, /\.woff(\?.*)?$/,
		/\.png(\?.*)?$/, /\.jpg(\?.*)?$/, /\.jpeg(\?.*)?$/, /\.gif(\?.*)?$/, /\.pdf(\?.*)?$/
	],

	// include all urls by default
	include: [/.*/],
開發者ID:0815fox,項目名稱:DefinitelyTyped,代碼行數:31,代碼來源:connect-livereload-tests.ts

示例3: serveSPA

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)
  );
}
開發者ID:jtborst,項目名稱:instaMoneyDashboard,代碼行數:14,代碼來源:server.ts

示例4: serveSPA

export function serveSPA(env) {
  let app = express();

  app.use(
    APP_BASE,
    connectLivereload({port: LIVE_RELOAD_PORT}),
    serveStatic(resolve(process.cwd(), PATH.dest[env].all))
  );

  app.all(APP_BASE + '*', (req, res) =>
    res.sendFile(resolve(process.cwd(), PATH.dest[env].all, 'index.html'))
  );

  app.listen(PORT, () =>
    openResource('http://localhost:' + PORT + APP_BASE)
  );
}
開發者ID:Anhmike,項目名稱:hotelbooking-angular2,代碼行數:17,代碼來源:utils.ts

示例5: serveSPA

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

  server.use(
    APP_BASE,
    connectLivereload({ port: LIVE_RELOAD_PORT }),
    serveStatic(resolve(process.cwd(), APP_DEST))
  );

  server.all(APP_BASE + '*', (req, res) =>
    res.sendFile(resolve(process.cwd(), APP_DEST, 'index.html'))
  );

  server.listen(PORT, () =>
    openResource('http://localhost:' + PORT + APP_BASE)
  );
}
開發者ID:kyutaekang,項目名稱:ionic2-seed,代碼行數:18,代碼來源:server.ts

示例6: connectLivereload

  }
};

let changed = files => {
  if (!(files instanceof Array)) {
    files = [files];
  }
  if (ENABLE_HOT_LOADING) {
    ng2HotLoader.onChange(files);
  } else {
    tinylr.changed({
      body: { files }
    });
  }
};

let tinylrMiddleware = connectLivereload({ port: LIVE_RELOAD_PORT });
let middleware = [
  APP_BASE,
  (req, res, next) => {
    if (ENABLE_HOT_LOADING) {
      next();
    } else {
      tinylrMiddleware(req, res, next);
    }
  },
  express.static(process.cwd())
];

export { listen, changed, middleware };
開發者ID:15921050052,項目名稱:SB-Admin-BS4-Angular-2,代碼行數:30,代碼來源:code_change_tools.ts

示例7: express

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

  server.use(compression());
  server.use(bodyParser.json());

  server.get('/imageids', (req, res) => {
    res.json({imageIds: randomImages.getIds()});
  });

  server.get('/lastmodified', (req, res) => {
    res.json(lastModified);
  });

  server.get('/errorconfig', (req, res) => {
    res.json(errorConfig);
  });

  /**
   * Validates user submission and sends the message received via the contact from
   *
   * @param {Object} submission
   * @param {string} submission.name
   * @param {string} submission.email
   * @param {string} submission.text
   * @param {string} submission.heuning
   */
  server.post('/send', (req, res) => {
    let submission:Submission = req.body,
      errors:Array<string> = mailHelper.validate(submission);

    if (errors.length > 0) {
      res.status(400).send({errors: errors});
    } else {

      let message:Message = mailHelper.buildMessage(submission),
        messageCopy:Message = mailHelper.buildMessageCopy(submission);

      nodeMailer.send(message, (success:boolean) => {
        if (success) {
          nodeMailer.send(messageCopy, (success:boolean) => {
            if (success) {
              res.status(200).json('Sent successfully');
            } else {
              res.sendStatus(500);
            }
          });
        } else {
          res.sendStatus(500);
        }
      });
    }
  });

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

  server.listen(PORT, () =>
    openResource('http://localhost:' + PORT + APP_BASE + APP_DEST)
  );
};
開發者ID:ouq77,項目名稱:portfolio-web,代碼行數:65,代碼來源:server.ts


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