/*
Serve assets in build mode, by concatenating and miniying resources.
169398
function (type, group) {
    var name = path.join(config.packed, group + '.' + type);
    var parsed = filter.get('target', type)(name) || name;
    var html = toHtml(type, path.join(config.root, parsed));
    var target = fss.target(parsed);
    if (fss.exists(target)) return html;

    log('packing', fss.baseRelative(target));
    var files = assetFiles(type, group);
    if (_.isArray(files) && files.length > 0) {
        filter.get('pack', type)(files, function(packed) {
            fss.writeFile(target, packed);
        });
    }

    return html;
}
171409
function copyAssets({ assetsDir }) {
  if (_shouldCopyAssets(assetsDir)) {
    fs.copySync(distDir, assetsDir, {
      filter: src => !/inline/.test(src)
    });
  }
}
1153415
def _serve_asset(self, path, gzipped_asset_bytes, request):
    """"""
    mimetype = mimetypes.guess_type(path)[0] or 'application/octet-stream'
    return http_util.Respond(
        request, gzipped_asset_bytes, mimetype, content_encoding='gzip')
145339
function build(previousFileSizes) {
  console.log('Creating an optimized production build...');

  let compiler = webpack(Object.assign({}, config, { mode: 'production' }));
  return new Promise((resolve, reject) => {
    compiler.run((err, stats) => {
      if (err) {
        return reject(err);
      }
      const messages = formatWebpackMessages(stats.toJson({}, true));
      if (messages.errors.length) {
        return reject(new Error(messages.errors.join('\n\n')));
      }
      if (process.env.CI && messages.warnings.length) {
        console.log(
          chalk.yellow(
            '\nTreating warnings as errors because process.env.CI = true.\n' +
              'Most CI servers set it automatically.\n'
          )
        );
        return reject(new Error(messages.warnings.join('\n\n')));
      }
      return resolve({
        stats,
        previousFileSizes,
        warnings: messages.warnings,
      });
    });
  });
}
167760
function deploy(mode, target, system, containerDef, container, out, cb) {
    var executor = prepareAndGetExecutor(target, out, 'deploying');
    executor.deploy(mode, target, system, containerDef, container, out, function(err) {
      cb(err);
    });
  }
983829
function build(options) {
  var args = [require.resolve(path.join('node-gyp', 'bin', 'node-gyp.js')), 'rebuild', '--verbose'].concat(
    ['libsass_ext', 'libsass_cflags', 'libsass_ldflags', 'libsass_library'].map(function(subject) {
      return ['--', subject, '=', process.env[subject.toUpperCase()] || ''].join('');
    })).concat(options.args);

  console.log('Building:', [process.execPath].concat(args).join(' '));

  var proc = spawn(process.execPath, args, {
    stdio: [0, 1, 2]
  });

  proc.on('exit', function(errorCode) {
    if (!errorCode) {
      afterBuild(options);
      return;
    }

    if (errorCode === 127 ) {
      console.error('node-gyp not found!');
    } else {
      console.error('Build failed with error code:', errorCode);
    }

    process.exit(1);
  });
}
881203
function concat(app) {
  var files = app.views.files;
  var css = '';

  for (var file in files) {
    if ('.css' != path.extname(file)) continue;
    css += files[file].contents.toString();
    delete files[file];
  }

  css = myth(css);
  app.files.addView('index.css', {
    contents: new Buffer(css)
  });
}
1069713
function AssetHandler(req, res, next, local = false) {
            const parsedUrl = url.parse(req.url);
            // Check if we have an asset for that url defined.
            /** @type {Asset} */
            const asset = self.assetBundle.assetForUrlPath(parsedUrl.pathname);

            if (!asset) return next();

            const processors = () => (
                addSourceMapHeader(asset, res),
                addETagHeader(asset, res),
                addCacheHeader(asset, res, req.url)
            );

            if (local) {
                return createStreamProtocolResponse(asset.getFile(), res, processors);
            }
            return send(
                req,
                encodeURIComponent(asset.getFile()),
                { etag: false, cacheControl: false }
            )
                .on('file', processors)
                .pipe(res);
        }
705160
function buildJs() {
  const jsFiles = config.jsCoreFiles;
  config.componentPaths.forEach(component => {
    jsFiles.push(path.join(component, '*.js'));
    jsFiles.push(path.join(component, '**/*.js'));
  });

  gutil.log("building js files...");

  const jsBuildStream = gulp.src(jsFiles)
  .pipe(filterNonCodeFiles())
  .pipe(utils.buildNgMaterialDefinition())
  .pipe(plumber())
  .pipe(ngAnnotate())
  .pipe(utils.addJsWrapper(true));

  const jsProcess = series(jsBuildStream, themeBuildStream())
  .pipe(concat('angular-material.js'))
  .pipe(BUILD_MODE.transform())
  .pipe(insert.prepend(config.banner))
  .pipe(insert.append(';window.ngMaterial={version:{full: "' + VERSION + '"}};'))
  .pipe(gulp.dest(config.outputDir))
  .pipe(gulpif(!IS_DEV, uglify({output: {comments: 'some'}})))
  .pipe(rename({extname: '.min.js'}))
  .pipe(gulp.dest(config.outputDir));

  return series(jsProcess, deployMaterialMocks());

  // Deploy the `angular-material-mocks.js` file to the `dist` directory
  function deployMaterialMocks() {
    return gulp.src(config.mockFiles)
    .pipe(gulp.dest(config.outputDir));
  }
}
982686
function buildRequiredAssets(self, context) {
  var paths   = context.__requiredPaths__.concat([ self.pathname ]),
      assets  = resolveDependencies(self, paths),
      stubs   = resolveDependencies(self, context.__stubbedAssets__);

  if (stubs.length > 0) {
    // exclude stubbed assets if any
    assets = _.filter(assets, function (path) {
      return stubs.indexOf(path) === -1;
    });
  }

  prop(self, '__requiredAssets__', assets);
}
1014113
private void compile(AssetInfo asset, File source, File target) throws ServiceException {
        File watched = watchedAssets.get(asset);
        if (watched == null) {
            if (isDevMode()) {
                new Thread(() -> {
                    try {
                        // avoid recursive compiles
                        if (isDevMode())
                            watchedAssets.put(asset, target);
                        doCompile(asset, source, target);
                    }
                    catch (Exception ex) {
                        logger.severeException(ex.getMessage(), ex);
                    }
                }).start();
            }
            else {
                doCompile(asset, source, target);
            }
        }
    }
127611
def build_assets(args):
    
    # Get the path to the JS directory
    asset_path = path.join(path.dirname(longclaw.__file__), 'client')
    try:
        # Move into client dir
        curdir = os.path.abspath(os.curdir)
        os.chdir(asset_path)
        print('Compiling assets....')
        subprocess.check_call(['npm', 'install'])
        subprocess.check_call(['npm', 'run', 'build'])
        os.chdir(curdir)
        print('Complete!')
    except (OSError, subprocess.CalledProcessError) as err:
        print('Error compiling assets:  {}'.format(err))
        raise SystemExit(1)
590546
public function buildWebPack()
    {
        $assets = $this->getMergedAssets();
        $modules = [];
        $moduleAssets = [];

        $buildPath = $this->config()->getItem('meliscore/ressources');
        $buildPath = $buildPath['build']['build_path'];
        $ds = '/';


        // get the module details via their assets info
        foreach ($assets['css'] as $idx => $asset) {

            $this->setCachedFile($asset);

            $fileFragments = explode($ds, $asset);
            $module = $fileFragments[1] ?? null;

            if ($module) {

                $modulePath = $this->module()->getModulePath($module);

                if ($modulePath) {

                    // check if the build directory for CSS exists
                    $cssBuildPath = $modulePath . $ds . $buildPath . $ds . 'css';
                    if (!file_exists($cssBuildPath)) {
                        @mkdir($cssBuildPath, 0777, true);
                    }

                    // make sure that the file has the right access
                    @chmod($cssBuildPath, 0777);

                    $modules[$module]['path'] = $modulePath;
                    if (preg_match("/$module/", $asset)) {
                        $modules[$module]['css'][] = preg_replace("/\/$module\//", $modulePath . $ds . 'public' . $ds, $asset, 1);
                    }
                }
            }
        }

        foreach ($assets['js'] as $idx => $asset) {

            $this->setCachedFile($asset);

            $fileFragments = explode('/', $asset);
            $module = $fileFragments[1] ?? null;

            if ($module) {

                $modulePath = $this->module()->getModulePath($module);

                if ($modulePath) {
                    // check if the build directory for JS exists
                    $jsBuildPath = $modulePath . $ds . $buildPath . $ds . 'js';
                    if (!file_exists($jsBuildPath)) {
                        @mkdir($jsBuildPath, 0777, true);
                    }

                    // make sure that the file has the right access
                    @chmod($jsBuildPath, 0777);

                    $modules[$module]['path'] = $modulePath;
                    if (preg_match("/$module/", $asset)) {
                        $modules[$module]['js'][] = preg_replace("/\/$module\//", $modulePath . $ds . 'public' . $ds, $asset, 1);
                    }
                }
            }
        }

        $mixScript = $this->mixFilePrefix();


        foreach ($modules as $key => $module) {
            $hasCss = $module['css'] ?? false;
            $hasJs = $module['js'] ?? false;

            $mixScript .= '// ' . $key . PHP_EOL;
            $path = $module['path'] . $ds . 'public' . $ds . 'build' . $ds;
            if ($hasCss) {
                $mixScript .= $this->getMixStyles($module['css'], $path . 'css' . $ds . 'bundle.css');
            }

            if ($hasJs) {
                $mixScript .= $this->getMixScripts($module['js'], $path . 'js' . $ds . 'bundle.js');
            }

        }

        $webPackPath = $_SERVER['DOCUMENT_ROOT'] . $ds;
        $mixScript .= $this->getCached();
        $webpack = $this->getWebPackMixFile();

        file_put_contents($webpack, $mixScript);
        @chmod($webpack, 0777);

        $runWebPackPath = str_replace('public/', '', $webPackPath);

        return "Webpack has been generated in $webpack\r\nRun \"npm run development\" or \"npm run production\" (if you want your assets to be minified) in $runWebPackPath to generate your bundled assets.";

    }
29272
function runRebase(options) {
    const platforms = detectPorting(options.platform);
    if (platforms.length <= 0) {
        return Promise.resolve();
    } else {
        const target = platforms[0];
        options.platform = target;
        runBuild(options)
        .then(() => {
            if ('dev' !== target) {
                const srcDir = path.join(__dirname, '..', config.dir.pkg, config.dir.porting + '_' + target);
                const dstDir = path.join(__dirname, '..', config.dir.pkg, config.dir.porting);
                if (fs.existsSync(srcDir)) {
                    fs.moveSync(srcDir, dstDir);
                }
            }
        })
        .catch((reason) => {
            console.error(reason);
            process.exit(1);
        });
    }
}
69821
function buildScripts() {
  return Promise.resolve()
    // Create the dist folder if it doesn't exist
    .then(() => {
      if(!FS.existsSync(Path.join(__dirname, 'dist'))) {
        return FS.mkdirAsync(Path.join(__dirname, 'dist'));
      }
    })

    // Generate minified scripts
    .then(() => new Promise((resolve, reject) => {
      let scripts = {
        'dropdowns.js': FS.readFileSync(Path.join(__dirname, 'source/js/dropdowns.js'), 'utf8'),
        'tabs.js': FS.readFileSync(Path.join(__dirname, 'source/js/tabs.js'), 'utf8')
      };

      let result = UglifyJS.minify(scripts, {
        output: {
          comments: /^!/
        }
      });
      if(result.error) {
        reject(result.error);
        return;
      }

      resolve(result.code);
    }))

    // Write minified scripts to dist
    .then((scripts) => {
      let file = Path.join(__dirname, 'dist/shoelace.js');

      // Update {{version}} in JS since it's not processed with Handlebars
      scripts = scripts.replace(/\{\{version\}\}/g, __version);

      // Output a message
      console.log(Chalk.green('JS processed: %s! 🐭'), Path.relative(__dirname, file));

      // Write output file
      return FS.writeFileAsync(file, scripts, 'utf8');
    });
}
759582
function buildOnce(config) {
  // verify config
  if (!lintConfig(config)) throw new Error('invalid config')

  // set default holder
  if (!config.holder) {
    config.holder = { name: 'app', stub: 'epii' }
  }

  // prepare static dir
  shell.mkdir('-p', config.$path.target.client)
  shell.mkdir('-p', config.$path.target.vendor)

  // process source
  pureRecipe(config, CONTEXT)
  viewRecipe(config, CONTEXT)
  sassRecipe(config, CONTEXT)
  fileRecipe(config, CONTEXT)
}
1315725
function serve(done) {
  gulp.watch(['src/**/*.css'], () => {
    reset();
    gulp.series('build-css', 'generate-preview', outputDevServerInfo);
  });

  gulp.watch(['previewer-src/**', 'patterns.yaml'], () => {
    reset();
    gulp.series('generate-preview-force', outputDevServerInfo)
  });

  browserSync.emitter.on('init', outputDevServerInfo);

  browserSync.init({
    logLevel: 'silent',
    ui: false,
    port: 4321,
    notify: false,
    server: {
      baseDir: __dirname + '/build',
      middleware: [historyApiFallback()],
    },
    startPath: '/',
    open: false
  });
}