def static(cache): """Copy other assets as is to the build path.""" for source in cache.assets(processed=False): logger.info('copying: ' + source.rel_path()) helpers.makedirs(source.dest_dir()) shutil.copyfile(source.path(), source.dest()) helpers.utime(source.dest(), source.updated()) source.processed(True)
def js(cache): """Minify JavaScript files to the build path.""" for source in cache.assets(ext='.js'): helpers.makedirs(source.dest_dir()) command = conf.get('min_js_cmd') if conf.get('min_js') and command: logger.info('minifying JavaScript: ' + source.rel_path()) helpers.execute(command, source.path(), source.dest()) else: logger.info('copying: ' + source.rel_path()) shutil.copyfile(source.path(), source.dest()) helpers.utime(source.dest(), source.updated()) source.processed(True)
def less(cache): """Compile and minify less files.""" for source in cache.assets(ext='.less'): helpers.makedirs(source.dest_dir()) logger.info('compiling LESS: ' + source.rel_path()) if conf.get('min_css') and conf.get('min_css_cmd'): tmp_file = os.path.join(source.dest_dir(), '_' + source.basename()) helpers.execute(conf.get('less_cmd'), source.path(), tmp_file) logger.info('minifying CSS: ' + source.rel_path()) helpers.execute(conf.get('min_css_cmd'), tmp_file, source.dest()) os.remove(tmp_file) else: helpers.execute(conf.get('less_cmd'), source.path(), source.dest()) helpers.utime(source.dest(), source.updated()) source.processed(True)