0.0.3 • Published 9 years ago

grunt-concat-src v0.0.3

Weekly downloads
1
License
-
Repository
github
Last release
9 years ago

concat-src

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.

Getting Started

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');

The "concat_src" task

Overview

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
    },
  },
});

Options

options.separator

Type: String Default value: ''

A string value that is used to do separate the files in the bundle

options.dest

Type: String Default value: 'dist'

Destination folder for bundle files

options.reflectPath

Type: Boolean Default value: false

Replicate the files original paths within the destination folder.

Usage Examples

Default Options

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'],
  },
});

Custom Options

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'],
  },
});

Contributing

Use editorconfig to ensure coding style is maintained. Add unit tests for any new or changed functionality. Lint and test your code using Grunt.

Release History

(Nothing yet)