{"_id":"grunt-browserify-alias","_rev":"39-a4ddbebfd4fbe790c17e4a54f8359f85","name":"grunt-browserify-alias","time":{"modified":"2022-06-18T14:31:47.931Z","created":"2015-02-20T13:27:22.977Z","0.1.0":"2015-02-20T13:27:24.182Z","0.1.1":"2015-02-20T13:50:36.490Z","0.1.2":"2015-02-20T13:57:00.300Z","0.1.3":"2015-02-20T14:12:23.435Z","0.1.4":"2015-02-20T21:48:58.993Z","0.1.5":"2015-02-21T08:48:36.500Z"},"maintainers":[{"name":"munkychop","email":"hello@ivanhayes.com"}],"description":"Map paths to JS files and directories for use as aliases so that modules can be require'd without messy relative file paths.","readme":"### This module has been renamed and moved to a new repository:\n\n**npm**\n[https://www.npmjs.com/package/browserify-alias-grunt](https://www.npmjs.com/package/browserify-alias-grunt)\n\n**Github**\n[https://github.com/munkychop/browserify-alias-grunt](https://github.com/munkychop/browserify-alias-grunt)\n\n\nAlthough this will remain here and continue to function in order to support legacy users, please start using **[browserify-alias-grunt](https://www.npmjs.com/package/browserify-alias-grunt)** instead.\n\n\n---------------------------------------------------------\n\n# grunt-browserify-alias\nMap paths to JS files and directories for use as aliases so that modules can be require'd without messy relative file paths.\n\n## Why use aliases?\n\nYou want to require modules from specific directories, without needing to use `../../../../some-module` to resolve relative paths.\n\nFor example, have a look at the following javascript directory structure:\n\n```\nroot project directory\n│\n├──•Gruntfile.js\n│\n└───src\n     │\n     └───js\n          │\n          └───app\n               │\n               ├──• app.js\n               │\n               ├───controller\n               │    │\n               │    └──sunshine\n               │       │\n               │       └──• sunshine-controller.js \n               │\n               └───model\n                    │\n                    └──sunshine\n                       │\n                       └──• sunshine-model.js \n\n\n```\n\nNow, say we want to `require` *sunshine-model* from within the *sunshine-controller* module. The standard old crappy way to do this is:\n\n```javascript\nrequire(\"../../../model/sunshine/sunshine-model\");\n```\n\nNow imagine that you refactor your code and modules get moved around. Suddenly, managing all those relative paths becomes even more of a pain in the butt.\n\nUsing *grunt-browserify-alias* at compile-time will allow you to `require` modules from the aliased directories you specify.\n\nNew hotness:\n\n```javascript\nrequire(\"model/sunshine/sunshine-model\");\n```\n\n## Usage\n\n### Installation\n\n```\nnpm install --save-dev grunt-browserify-alias\n```\n\n### Implementation\n\nSimply specify the files and directories you want to map by using a globbing pattern. Here is a very basic Gruntfile as an example:\n\n```javascript\nfunction Gruntfile (grunt)\n{\n    \"use strict\";\n\n    var alias = require(\"grunt-browserify-alias\");\n\n    grunt.initConfig({\n\n        browserify: {\n            options : {\n                alias: alias.map(grunt, {\n\n                    // alias all js files in the 'app' directory\n                    cwd: \"src/js/app\",\n                    src: [\"**/*.js\"],\n                    dest: \"\"\n                })\n            },\n\n            src: \"src/js/app/app.js\",\n            dest: \"dist/js/app.js\",\n        },\n    });\n\n\n    grunt.loadNpmTasks(\"grunt-browserify\");\n\n    grunt.registerTask(\"default\", [\"browserify\"]);\n}\n\nmodule.exports = Gruntfile;\n```\n\n\nIt is also possible to specify multiple targets using an array of objects:\n\n```javascript\nfunction Gruntfile (grunt)\n{\n    \"use strict\";\n\n    var alias = require(\"grunt-browserify-alias\");\n\n    grunt.initConfig({\n\n        browserify: {\n            options : {\n                alias: alias.map(grunt, [\n                    {\n                        // alias app files\n                        cwd: \"src/js/app\",\n                        src: [\"**/*.js\"],\n                        dest: \"\"\n                    },\n                    {\n                        // alias lib files\n                        cwd: \"src/js/libs\",\n                        src: [\"**/*.js\"],\n                        dest: \"\"\n                    }\n                ])\n            },\n\n            src: \"src/js/app/app.js\",\n            dest: \"dist/js/app.js\",\n        },\n    });\n\n\n    grunt.loadNpmTasks(\"grunt-browserify\");\n\n    grunt.registerTask(\"default\", [\"browserify\"]);\n}\n\nmodule.exports = Gruntfile;\n```","versions":{"0.1.4":{"name":"grunt-browserify-alias","title":"grunt-browserify-alias","description":"Map paths to JS files and directories for use as aliases so that modules can be require'd without messy relative file paths.","version":"0.1.4","private":false,"repository":{"type":"git","url":"https://github.com/munkychop/grunt-browserify-alias"},"bugs":{"url":"https://github.com/munkychop/grunt-browserify-alias/issues"},"engines":{"node":">=0.8.0"},"keywords":[],"_id":"grunt-browserify-alias@0.1.4","dist":{"shasum":"984a9b42a65c35f0bfe440905c3997773086fa66","tarball":"https://registry.npmjs.org/grunt-browserify-alias/-/grunt-browserify-alias-0.1.4.tgz","integrity":"sha512-yuVhWhXXR2jrdRPhvnGrK7vnw/HCe/vcGUpUTzWonTKgjriH5vFHq7tRWIVnEdDlFfHkSMwzVGNEZeINdXnDLQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDwHv8Ef09kHaSgwscucII/sabPI519PEKyeZktsebMmAIhAPjROeRHFUmGaWLkSxEa8zvs9p3xsz4cmVOYzdyN0isJ"}]},"_from":".","_npmVersion":"1.3.7","_npmUser":{"name":"munkychop","email":"hello@ivanhayes.com"},"maintainers":[{"name":"munkychop","email":"hello@ivanhayes.com"}],"deprecated":"Moved"},"0.1.5":{"name":"grunt-browserify-alias","title":"grunt-browserify-alias","description":"Map paths to JS files and directories for use as aliases so that modules can be require'd without messy relative file paths.","version":"0.1.5","private":false,"repository":{"type":"git","url":"https://github.com/munkychop/grunt-browserify-alias"},"main":"grunt-browserify-alias.js","bugs":{"url":"https://github.com/munkychop/grunt-browserify-alias/issues"},"licenses":[{"type":"MIT","url":"https://github.com/munkychop/grunt-browserify-alias/blob/master/LICENSE"}],"engines":{"node":">=0.8.0"},"keywords":[],"_id":"grunt-browserify-alias@0.1.5","dist":{"shasum":"c134dc2d780c31497580fd1c9881fb4ea764186c","tarball":"https://registry.npmjs.org/grunt-browserify-alias/-/grunt-browserify-alias-0.1.5.tgz","integrity":"sha512-U7lMc6dGIDj2dDhHC7K9bw3fS2LJPTU4mQEVPejw6UNyS9fQ6XPZc2iSNm4bgB/Eok3Lq4F5Tnc3faghWBaM7w==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDC68OVYwXBZW0rTZrG5qu0ZELuyuY2Olel0Vb/Cb0mzAIgbhcYK1eSK5AoPM3N8hmzvhwYgMuk6qFul9NLcgIGzRY="}]},"_from":".","_npmVersion":"1.3.7","_npmUser":{"name":"munkychop","email":"hello@ivanhayes.com"},"maintainers":[{"name":"munkychop","email":"hello@ivanhayes.com"}],"deprecated":"Moved to https://www.npmjs.com/package/browserify-alias-grunt"}},"dist-tags":{"latest":"0.1.5"},"readmeFilename":"README.md","keywords":[],"repository":{"type":"git","url":"https://github.com/munkychop/grunt-browserify-alias"},"bugs":{"url":"https://github.com/munkychop/grunt-browserify-alias/issues"}}