Gathering detailed insights and metrics for grunt-ordered-concat
Gathering detailed insights and metrics for grunt-ordered-concat
Gathering detailed insights and metrics for grunt-ordered-concat
Gathering detailed insights and metrics for grunt-ordered-concat
npm install grunt-ordered-concat
Typescript
Module System
Min. Node Version
Node Version
NPM Version
JavaScript (98.15%)
HTML (1.05%)
CSS (0.8%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
164 Commits
2 Watchers
1 Branches
1 Contributors
Updated on Aug 30, 2019
Latest Version
1.0.1
Package Id
grunt-ordered-concat@1.0.1
Size
8.63 kB
NPM Version
2.14.7
Node Version
4.2.3
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
2
1
Concatenate files allowing for simple dependency specification.
If you haven't used Grunt before, be sure to check out the Getting Started guide, as it explains how to create a Gruntfile as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:
1npm install grunt-ordered-concat --save-dev
Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:
1grunt.loadNpmTasks('grunt-ordered-concat');
Run this task with the grunt oconcat
command.
Task targets, files and options may be specified according to the Grunt Configuring tasks guide.
Type: String
Default: grunt.util.linefeed
Concatenated files will be joined on this string. If you're post-processing concatenated JavaScript files with a minifier, you may need to use a semicolon ';\n'
as the separator.
Type: String
Default: ''
This string will be prepended to the beginning of the concatenated output. It is processed using grunt.template.process, using the default options.
(Default processing options are explained in the grunt.template.process documentation)
Type: String
Default: ''
This string will be appended to the end of the concatenated output. It is processed using grunt.template.process, using the default options.
(Default processing options are explained in the grunt.template.process documentation)
Type: Boolean
Object
Default: false
Strip JavaScript banner comments from source files.
false
- No comments are stripped.true
- /* ... */
block comments are stripped, but NOT /*! ... */
comments.options
object:
true
were specified.block
- If true, all block comments are stripped.line
- If true, any contiguous leading //
line comments are stripped.Type: Boolean
Object
Function
Default: false
Process source files before concatenating, either as templates or with a custom function.
false
- No processing will occur.true
- Process source files using grunt.template.process defaults.data
object - Process source files using grunt.template.process, using the specified options.function(src, filepath)
- Process source files using the given function, called once for each file. The returned value will be used as source code.(Default processing options are explained in the grunt.template.process documentation)
Type: String
Default: .
Set to project's root directory (for dependency purposes) is different than the parent directory of Gruntfile.js.
Type: Boolean
Default: false
Set to true to create a source map. The source map will be created alongside the destination file, and share the same file name with the .map
extension appended to it.
Type: String
Function
Default: undefined
To customize the name or location of the generated source map, pass a string to indicate where to write the source map to. If a function is provided, the oconcat destination is passed as the argument and the return value will be used as the file name.
Type: String
Default: embed
Determines the type of source map that is generated. The default value, embed
, places the content of the sources directly into the map. link
will reference the original sources in the map as links. inline
will store the entire map as a data URI in the destination file.
This example demonstrates how to ensure certain files are concatenated before other files. Using the dependsOn() directive anywhere in a source file will ensure that the indicated file (which also must be included in the source) is placed concatenated before this file.
1dependsOn("path/relative/to/file.js"); 2dependsOn("/path/relative/to/project/file.js");
In this example, running grunt oconcat:dist
(or grunt oconcat
because oconcat
is a multi task) will concatenate the three specified source files (in order), joining files with ;
and writing the output to dist/built.js
.
1// Project configuration.
2grunt.initConfig({
3 oconcat: {
4 options: {
5 separator: ';',
6 },
7 dist: {
8 src: ['src/intro.js', 'src/project.js', 'src/outro.js'],
9 dest: 'dist/built.js',
10 },
11 },
12});
In this example, running grunt oconcat:dist
will first strip any preexisting banner comment from the src/project.js
file, then concatenate the result with a newly-generated banner comment, writing the output to dist/built.js
.
This generated banner will be the contents of the banner
template string interpolated with the config object. In this case, those properties are the values imported from the package.json
file (which are available via the pkg
config property) plus today's date.
Note: you don't have to use an external JSON file. It's also valid to create the pkg
object inline in the config. That being said, if you already have a JSON file, you might as well reference it.
1// Project configuration. 2grunt.initConfig({ 3 pkg: grunt.file.readJSON('package.json'), 4 oconcat: { 5 options: { 6 stripBanners: true, 7 banner: '/*! <%= pkg.name %> - v<%= pkg.version %> - ' + 8 '<%= grunt.template.today("yyyy-mm-dd") %> */', 9 }, 10 dist: { 11 src: ['src/project.js'], 12 dest: 'dist/built.js', 13 }, 14 }, 15});
In this example, running grunt oconcat
will build two separate files. One "basic" version, with the main file essentially just copied to dist/basic.js
, and another "with_extras" concatenated version written to dist/with_extras.js
.
While each oconcat target can be built individually by running grunt oconcat:basic
or grunt oconcat:extras
, running grunt oconcat
will build all oconcat targets. This is because oconcat
is a multi task.
1// Project configuration.
2grunt.initConfig({
3 oconcat: {
4 basic: {
5 src: ['src/main.js'],
6 dest: 'dist/basic.js',
7 },
8 extras: {
9 src: ['src/main.js', 'src/extras.js'],
10 dest: 'dist/with_extras.js',
11 },
12 },
13});
Like the previous example, in this example running grunt oconcat
will build two separate files. One "basic" version, with the main file essentially just copied to dist/basic.js
, and another "with_extras" concatenated version written to dist/with_extras.js
.
This example differs in that both files are built under the same target.
Using the files
object, you can have list any number of source-destination pairs.
1// Project configuration.
2grunt.initConfig({
3 oconcat: {
4 basic_and_extras: {
5 files: {
6 'dist/basic.js': ['src/main.js'],
7 'dist/with_extras.js': ['src/main.js', 'src/extras.js'],
8 },
9 },
10 },
11});
Filenames can be generated dynamically by using <%= %>
delimited underscore templates as filenames.
In this example, running grunt oconcat:dist
generates a destination file whose name is generated from the name
and version
properties of the referenced package.json
file (via the pkg
config property).
1// Project configuration. 2grunt.initConfig({ 3 pkg: grunt.file.readJSON('package.json'), 4 oconcat: { 5 dist: { 6 src: ['src/main.js'], 7 dest: 'dist/<%= pkg.name %>-<%= pkg.version %>.js', 8 }, 9 }, 10});
In this more involved example, running grunt oconcat
will build two separate files (because oconcat
is a multi task). The destination file paths will be expanded dynamically based on the specified templates, recursively if necessary.
For example, if the package.json
file contained {"name": "awesome", "version": "1.0.0"}
, the files dist/awesome/1.0.0/basic.js
and dist/awesome/1.0.0/with_extras.js
would be generated.
1// Project configuration. 2grunt.initConfig({ 3 pkg: grunt.file.readJSON('package.json'), 4 dirs: { 5 src: 'src/files', 6 dest: 'dist/<%= pkg.name %>/<%= pkg.version %>', 7 }, 8 oconcat: { 9 basic: { 10 src: ['<%= dirs.src %>/main.js'], 11 dest: '<%= dirs.dest %>/basic.js', 12 }, 13 extras: { 14 src: ['<%= dirs.src %>/main.js', '<%= dirs.src %>/extras.js'], 15 dest: '<%= dirs.dest %>/with_extras.js', 16 }, 17 }, 18});
If you would like the oconcat
task to warn if a given file is missing or invalid be sure to set nonull
to true
:
1grunt.initConfig({ 2 oconcat: { 3 missing: { 4 src: ['src/invalid_or_missing_file'], 5 dest: 'compiled.js', 6 nonull: true, 7 }, 8 }, 9});
See configuring files for a task for how to configure file globbing in Grunt.
If you would like to do any custom processing before concatenating, use a custom process function:
1grunt.initConfig({
2 oconcat: {
3 dist: {
4 options: {
5 // Replace all 'use strict' statements in the code with a single one at the top
6 banner: "'use strict';\n",
7 process: function(src, filepath) {
8 return '// Source: ' + filepath + '\n' +
9 src.replace(/(^|\n)[ \t]*('use strict'|"use strict");?\s*/g, '$1');
10 },
11 },
12 files: {
13 'dist/built.js': ['src/project.js'],
14 },
15 },
16 },
17});
charset:utf-8
to sourceMappingURL
.sourceMap
option.this.files
API.this.file
API internally.Task submitted by "Cowboy" Ben Alman
This file was generated on Wed Apr 20 2016 08:41:44.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
Found 0/30 approved changesets -- score normalized to 0
Reason
no SAST tool detected
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Score
Last Scanned on 2025-06-30
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More