Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,12 @@ grunt.initConfig({
closurePath: '/src/to/closure-compiler',
js: 'static/src/frontend.js',
jsOutputFile: 'static/js/frontend.min.js',
sourceMapUrl: true,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't see the point in this option, should just check for options.create_source_map

maxBuffer: 500,
options: {
compilation_level: 'ADVANCED_OPTIMIZATIONS',
language_in: 'ECMASCRIPT5_STRICT'
language_in: 'ECMASCRIPT5_STRICT',
create_source_map: 'src.js.map'
}
}
}
Expand All @@ -42,6 +44,8 @@ grunt.initConfig({

If `jsOutputFile` property is set, the script will be minified and saved to the file specified. Otherwise it will be output to the command line.

If the `sourceMapUrl` property is set to a truthy value, the sourceMappingURL comment is appended to the generated JS file. If you pass this property as a string value, the sourceMappingURL will be set to that value. Otherwise, boolean true assumes the file name with a .map extension.

`maxBuffer` property

If the buffer returned by closure compiler is more than 200kb, you will get an error saying "maxBuffer exceeded". To prevent this, you can set the maxBuffer to the preffered size you want (in kb)
Expand Down
11 changes: 11 additions & 0 deletions tasks/closure-compiler.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,17 @@ module.exports = function(grunt) {
done(false);
}

// Check to see if we should add the source map comment to end of file
if (data.sourceMapUrl && data.options.create_source_map) {
if (typeof data.sourceMapUrl == 'boolean') {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps you could modify the create_source_map if it's boolean true. The correct way to check that would be if(data.options.create_source_map === true)

data.sourceMapUrl = path.basename(data.options.create_source_map);
}

fs.appendFile(data.jsOutputFile, '//# sourceMappingURL=' + data.sourceMapUrl, function (err) {
grunt.log.writeln('Could not add sourceMappingURL!');
});
}

if (stdout) {
grunt.log.writeln(stdout);
}
Expand Down