How to use brunch - 2 common examples

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);
github aframevr-userland / aframe-cli / lib / build.js View on Github external
return new Promise((resolve, reject) => {
    filePath = filePath || process.cwd();
    options = options || {};
    options.config = options.config || getBrunchConfigPath(filePath, options);
    logger.log(`Building project "${filePath}" …`);

    try {
      brunch.build(options, resolve);
    } catch (err) {
      logger.error(`Could not build project "${filePath}" …`);
      throw err;
    }
  }).then(() => {
    let builtPath = null;

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 2 years ago

Package Health Score

53 / 100
Full package analysis

Popular brunch functions