How to use the brunch.watch function in brunch

To help you get started, we’ve selected a few brunch examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github aframevr-userland / aframe-cli / lib / serve.js View on Github external
watchPath = watchPath || process.cwd();
  options = options || {};
  options.config = options.config || getBrunchConfigPath(watchPath, options);
  options.server = true;
  options.network = true;

  const optionsFile = require(options.config);

  logger.log(`Watching "${watchPath}" …`);

  // Copy the server URL to the user's clipboard.
  const port = (optionsFile.server && optionsFile.server.port) || 3333;
  const https = options.https || options.ssl || options.secure || false;
  const serverUrl = `http${https ? 's' : ''}://localhost:${port}/`;
  try {
    const watcher = brunch.watch(options, () => {
      // saves preview videos from recorder component.
      watcher.server.on('request', function (req, res) {
        const method = req.method.toLowerCase();
        const pathname = url.parse(req.url).pathname;

        if (method === 'post' && pathname === '/upload') {
          let form = new formidable.IncomingForm();
          let files = [];

          form.encoding = 'binary';
          form.keepExtensions = true;
          form.multiple = true;

          const uploadDir = path.join(watchPath, 'app/assets/video/');

          fs.ensureDir(uploadDir);

brunch

Fast front-end web app build tool with simple declarative config, seamless incremental compilation for rapid development, an opinionated pipeline and workflow, and core support for source maps

MIT
Latest version published 1 year ago

Package Health Score

53 / 100
Full package analysis

Popular brunch functions