Parse src attributes and concat into a bundle.js. Made to modernise the build tools for a legacy project that contains a lot of circa 2010 document.write() approach to loading js files.
This plugin requires Grunt ~0.4.5
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:
npm install concat-src --save-dev
Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:
grunt.loadNpmTasks('concat-src');
In your project's Gruntfile, add a section named concat_src
to the data object passed into grunt.initConfig()
.
grunt.initConfig({
concat_src: {
options: {
// Task-specific options go here.
},
yourFileList: [
// Target-specific file lists
},
},
});
Type: String
Default value: ''
A string value that is used to do separate the files in the bundle
Type: String
Default value: 'dist'
Destination folder for bundle files
Type: Boolean
Default value: false
Replicate the files original paths within the destination folder.
No custom options, the assets listed in the two files will be concatenated into two bundles at dist/docwrite.js & dist/scripts.js
grunt.initConfig({
concat_src: {
options: {},
files: ['src/docwrite.js', 'src/scripts.js'],
},
});
All options set. The bundles will have a custom string between each concatenated asset. The assets listed in the two files will be concatenated into two bundles at build/some/deep/folder/docwrite.js & build/lib/scripts.js
Any assets that contain in their path, 'legacyPath/' will have this removed.
grunt.initConfig({
concat_src: {
options: {
separator: ' /* --- end of file --- */ ',
dest: 'build',
reflectPath: true,
convertPaths:[
{
from:'legacyPath/',
to:''
}
]
},
files: ['some/deep/folder/docwrite.js', 'lib/scripts.js'],
},
});
Use editorconfig to ensure coding style is maintained. Add unit tests for any new or changed functionality. Lint and test your code using Grunt.
(Nothing yet)