You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on May 9, 2021. It is now read-only.
JSMin is a JavaScript minifier that removes whitespace and comments.
Source maps enables developers to view and interact with minified JavaScript as if it were unminified (providing useful line errors and easier debugging).
When you combine all three of these, you get a grunt plugin that is your new best debugging friend.
Demos
The demos in the node-jsmin-sourcemap, what makes this tick, are hosted on Plunker for your testing and enjoyment.
Install this grunt plugin next to your project's grunt.js gruntfile with: npm install grunt-jsmin-sourcemap
Then add this line to your project's grunt.js gruntfile:
grunt.loadNpmTasks('grunt-jsmin-sourcemap');
Documentation
grunt-jsmin-sourcemap is registered under the jsmin-sourcemap task. Your initConfig should look similar to this:
grunt.initConfig({'jsmin-sourcemap': {all: {// Source files to concatenate and minify (also accepts a string and minimatch items)src: ['public/js/jquery.js','public/js/underscore.js'],// Destination for concatenated/minified JavaScriptdest: 'dist/js/all.min.js',// Destination for sourcemap of minified JavaScriptdestMap: 'dist/js/all.js.map'// Optional root for all relative URLssrcRoot: 'some/lower/directory'// Optional cwd to resolve from for all URLs// Converts jquery.js -> some/higher/directory/jquery.js during lookup but mapping preserves jquery.js in map filecwd: 'some/higher/directory'},// Compact format is also accepted'dest/file.js': ['src/file1.js','src/file2.js']}});
Contributing
In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint via grunt and test via npm test.