• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript connect-livereload类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了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;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript connect-mongo类代码示例发布时间:2022-05-28
下一篇:
TypeScript connect-history-api-fallback类代码示例发布时间:2022-05-28
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap