You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

broccoli

Package Overview
Dependencies
Maintainers
5
Versions
72
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

broccoli

Fast client-side asset builder

3.5.2
latest
Source
npm
Version published
Weekly downloads
262K
-30.64%
Maintainers
5
Weekly downloads
 
Created

What is broccoli?

Broccoli is a JavaScript build tool that allows you to define a build pipeline using a series of plugins. It is particularly well-suited for front-end development, enabling tasks such as file transformation, concatenation, and minification.

What are broccoli's main functionalities?

File Transformation

This code demonstrates how to use Broccoli to transform files. It uses the Funnel plugin to include only JavaScript files from the 'app' and 'vendor' directories and then merges these trees into a single output tree.

const Broccoli = require('broccoli');
const Funnel = require('broccoli-funnel');
const MergeTrees = require('broccoli-merge-trees');

let appTree = new Funnel('app', {
  include: ['**/*.js']
});

let vendorTree = new Funnel('vendor', {
  include: ['**/*.js']
});

let finalTree = new MergeTrees([appTree, vendorTree]);

module.exports = finalTree;

File Concatenation

This code demonstrates how to concatenate JavaScript files using the broccoli-concat plugin. It takes all JavaScript files in the 'app' directory and concatenates them into a single file, 'app.js', in the 'assets' directory.

const Broccoli = require('broccoli');
const Concat = require('broccoli-concat');

let appJs = new Concat('app', {
  outputFile: '/assets/app.js',
  inputFiles: ['**/*.js'],
  sourceMapConfig: { enabled: true }
});

module.exports = appJs;

File Minification

This code demonstrates how to minify JavaScript files using the broccoli-uglify-sourcemap plugin. It takes all JavaScript files in the 'app' directory and minifies them, with source maps enabled.

const Broccoli = require('broccoli');
const UglifyJS = require('broccoli-uglify-sourcemap');

let appJs = new UglifyJS('app', {
  mangle: true,
  compress: true,
  sourceMapConfig: { enabled: true }
});

module.exports = appJs;

Other packages similar to broccoli

Keywords

asset

FAQs

Package last updated on 03 May 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts