当前位置: 首页>>代码示例>>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;未经允许,请勿转载。