-
Notifications
You must be signed in to change notification settings - Fork 48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added support for source maps #42
Conversation
Added source map support for this plugin, also added documentation.
Thanks Benjamin. grunt.initConfig({
'closure-compiler': {
frontend: {
closurePath: '/src/to/closure-compiler',
js: 'static/src/frontend.js',
options: {
create_source_map: 'src.map',
source_map_format: 'V3'
}
}
}
}); |
Updated to use options object for Source Map generation.
Thanks for your response Guillaume, I totally missed that in the documentation. Creating the maps with the options object works great! Go ahead and ignore this request. I've modified my code to only include the "sourceMapUrl" option, which appends the sourceMapUrl comment to the end of the generated JS file which associates the two together. I have no idea why this isn't built into Closure Compiler by default, but I wasn't able to find any documentation on a flag to turn this on. I'm working in a Jenkins environment where hand editing files is a no go and this way we don't have to manage a bunch of X-SourceMap headers on the files. I'll add a new pull request for just this code. Thanks! |
Added a new pull request for just the sourceMapUrl feature: #43 Thanks again for pointing this out Guillaume! |
I'm using this along with the grunt watch plugin and it's adding the map to my root directory. IMO it should go into the same folder as the compiled JS. |
@@ -94,6 +94,15 @@ 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') data.sourceMapUrl = path.basename(data.jsOutputFile) + '.map'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't checking for "truthy", you should use if data.sourceMapUrl === true
I'm a Closure-compiler project maintainer. You do not need any special options - you should use the |
Added source map support for this plugin, also added documentation.