Security News
The Risks of Misguided Research in Supply Chain Security
Snyk's use of malicious npm packages for research raises ethical concerns, highlighting risks in public deployment, data exfiltration, and unauthorized testing.
broccoli-concat
Advanced tools
The broccoli-concat npm package is a Broccoli plugin used to concatenate multiple files into a single file. It is commonly used in build processes to combine JavaScript, CSS, or other types of files to reduce the number of HTTP requests and improve load times.
Concatenate JavaScript files
This feature allows you to concatenate all JavaScript files in the 'src/js' directory into a single file named 'app.js' in the 'assets' directory. Source maps are also enabled for easier debugging.
const concat = require('broccoli-concat');
const jsTree = concat('src/js', {
outputFile: '/assets/app.js',
inputFiles: ['**/*.js'],
sourceMapConfig: { enabled: true }
});
Concatenate CSS files
This feature allows you to concatenate all CSS files in the 'src/css' directory into a single file named 'styles.css' in the 'assets' directory. Source maps are also enabled for easier debugging.
const concat = require('broccoli-concat');
const cssTree = concat('src/css', {
outputFile: '/assets/styles.css',
inputFiles: ['**/*.css'],
sourceMapConfig: { enabled: true }
});
Custom file ordering
This feature allows you to specify a custom order for the files to be concatenated. In this example, 'jquery.js' and 'underscore.js' are concatenated first, followed by all other JavaScript files in the 'src/js' directory.
const concat = require('broccoli-concat');
const orderedJsTree = concat('src/js', {
outputFile: '/assets/app.js',
inputFiles: ['vendor/jquery.js', 'vendor/underscore.js', '**/*.js'],
sourceMapConfig: { enabled: true }
});
gulp-concat is a Gulp plugin that concatenates files. It is similar to broccoli-concat but is used within the Gulp build system. It offers similar functionality but is more commonly used in Gulp-based workflows.
webpack-concat-plugin is a Webpack plugin that concatenates files. It is similar to broccoli-concat but is used within the Webpack build system. It offers additional features like dependency resolution and is more commonly used in Webpack-based workflows.
grunt-contrib-concat is a Grunt plugin that concatenates files. It is similar to broccoli-concat but is used within the Grunt build system. It offers similar functionality but is more commonly used in Grunt-based workflows.
This filter is designed to be fast & good enough. It can generates source maps substantially faster than you'll get via mozilla/source-map, because it's special-cased for straight line-to-line contenation.
It discovers input sourcemaps in relative URLs, including data URIs.
const node = concat(node);
const node = concat(node, {
outputFile: '/output.js',
header: ";(function() {",
headerFiles: ['loader.js'],
inputFiles: ['**/*'],
footerFiles: ['auto-start.js'],
footer: "}());",
sourceMapConfig: { enabled: true },
allowNone: false | true // defaults to false, and will error if trying to concat but no files are found.
});
The structure of output.js
will be as follows:
// - header
// - ordered content of the files in headerFiles
// - un-ordered content of files matched by inputFiles, but not in headerFiles or footerFiles
// - ordered content of the files in footerFiles
// - footer
note: this is intended for debugging purposes only, and will most likely negatively affect your build performace is left enabled
Setting the environment variable CONCAT_STATS=true
will result a summary of
each concatention being output to process.cwd() + 'concat-stats-for/*.json'
Each file within that directory represents a different contenation, and will contain:
Want more details? like uglified or compressed sizes? (or have more ideas) go checkout: https://github.com/stefanpenner/broccoli-concat-analyser
concat-stats-for/-file.json
{
"outputFile": "path/to/output/File",
"sizes": {
"a.js": 5,
"b.js": 10,
}
}
other files:
FAQs
Fast, good-enough concatenation with source maps.
We found that broccoli-concat demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 6 open source maintainers collaborating on the project.
Did you know?
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.
Security News
Snyk's use of malicious npm packages for research raises ethical concerns, highlighting risks in public deployment, data exfiltration, and unauthorized testing.
Research
Security News
Socket researchers found several malicious npm packages typosquatting Chalk and Chokidar, targeting Node.js developers with kill switches and data theft.
Security News
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.