{"name":"gatsby-plugin-root-import","description":"Gatsby plugin to set Webpack to resolve import root","version":"2.0.4","license":"MIT","author":{"name":"Mong-Kuen Sun","email":"mongkuen.sun@gmail.com"},"homepage":"https://github.com/mongkuen/gatsby-plugin-root-import","bugs":{"url":"https://github.com/mongkuen/gatsby-plugin-root-import/issues"},"repository":{"type":"git","url":"git+https://github.com/mongkuen/gatsby-plugin-root-import.git"},"keywords":["gatsby","gatsby-plugin","import","root"],"main":"index.js","scripts":{"dev":"concurrently \"yarn run prettier-watch\" \"yarn run build-watch\" --kill-others","prettier-watch":"onchange 'src/**/*.js' 'src/**/*.jsx' -- prettier --write {{changed}}","build-watch":"onchange 'src/**/*.js' 'src/**/*.jsx' -- yarn run build","build":"babel src --out-dir .","prepublishOnly":"npm run build"},"devDependencies":{"babel-cli":"^6.26.0","babel-preset-es2015":"^6.24.1","babel-preset-stage-2":"^6.24.1","babel-runtime":"^6.26.0","concurrently":"^3.6.1","onchange":"^3.3.0","prettier":"^1.12.1"},"peerDependencies":{"gatsby":">=1"},"gitHead":"ed9c84bcb94913d14e37b8acd724ee87e29c2c3c","_id":"gatsby-plugin-root-import@2.0.4","_npmVersion":"5.6.0","_nodeVersion":"8.11.3","_npmUser":{"name":"mongkuen","email":"mongkuen.sun@gmail.com"},"dist":{"integrity":"sha512-moYTVSZgItAC2/hJ/+QBnJSmnVAkYZ+oGH5k0WUwpPf49cfAF3bHh9ZHCF+5Zf4viq42n4z7teIGB5/VsjcNQQ==","shasum":"262c01c2384df498369a808b1741379527ecb57f","tarball":"http://registry-npm.ywwl.com/gatsby-plugin-root-import/download/gatsby-plugin-root-import-2.0.4.tgz","fileCount":7,"unpackedSize":68760,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJbdNdqCRA9TVsSAnZWagAAJ74P/2wfyp5duS8cgAk6dIUR\nOHYbLkmyGC51rI+fu7+NQP1/aRud8NyGZmjRl3HSxB3GjUkNwXsFDid3bE5R\nzi5YUsV1DM9uJet1miUjVBfMBVaXaTyt7d3BZmP8qSNSk0U5WJkEyXjR6dJd\ngAOcP6IxQ+Da2/T4igFTEKl36qSYSvSKYBcJgBRC4R/3oNWp/iDAN5s0rYZ1\nyjzkHisHJ63GIji1kdYkKPTr/XoPL9B/Mlbb0KSUncFWMymlS9MGnNYOiofI\nLbs6fFxk0yHzbDf80YMxTXv8wGg82a2MbFneXYLComYrFf3RjkOhu/7B2N5t\npkOVHC77NrLVK8CVREoA+G/iV7yD7qpVr9tsmITP8kGzvFgrTqo7EVmYhrJJ\nelqcXFghKy92OHiX6VYxVSISViJAw95p9u538n7txTDAx+ndwkH2Ig0N8yFo\nxHKby8rUIX1y+aZ0D65iqYlPzS205a6kgq3J4FVF4PbjnsP7AgixutEFV0QZ\ngMVNrWOzx+R1qzOyRP3NwSakK5igsJmdeguALAa5czRDvK2bitjaqAbD348+\nXiJhM8VVC1EHbLtcWAvpRzKoK0DOIJdmTQsYJKtuaWn/Q8UmKAYt7HfgNvJL\nk5q/OyHiYC/HQL3InhRw223YNiMFQU8pxht/y3Q0BE8duW2KKZVmpuiIjPJZ\nGqMb\r\n=5p2b\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIEBsYHmm0zncYxZEDpMkyFcKWW5M4WrFbBd0qYAlVyQIAiBwaD49idNSClf31SdV5gobxvzLxZH/mB8Mh0oHEAzeTg=="}],"size":18309,"noattachment":false,"key":"/gatsby-plugin-root-import/-/gatsby-plugin-root-import-2.0.4.tgz"},"maintainers":[{"name":"mongkuen","email":"mongkuen.sun@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/gatsby-plugin-root-import_2.0.4_1534383977987_0.1580141132151176"},"_hasShrinkwrap":false,"readme":"# gatsby-plugin-root-import\n\nSet Webpack to resolve modules and aliases, allowing you to import modules from an absolute project path rather than relative `../../` paths.\n\n### Install\n\n1. Install the `gatsby-plugin-root-import` plugin:\n\n   `npm install --save-dev gatsby-plugin-root-import`\n\n   or\n\n   `yarn add --dev gatsby-plugin-root-import`\n\n### Usage\n\nAdd into `gatsby-config.js`.\n\n```javascript\n// gatsby-config.js\n\nmodule.exports = {\n  plugins: [\"gatsby-plugin-root-import\"],\n};\n```\n\n### Default Settings\n\nIf no options are specified, the plugin allows you access to the `src` folder and also it's contents automatically.\n\nThis means you should be able to import modules like such:\n\n```javascript\n// importing gatsbyProject/src/someFolder/SomeComponent.js\n\nimport SomeComponent from \"src/someFolder/SomeComponent\";\n// or more succinctly\nimport SomeComponent from \"someFolder/SomeComponent\";\n```\n\n### Plugin Options\n\nPlugin Options allows you to:\n\n1. Specify additional webpack [`resolve.modules`](https://webpack.js.org/configuration/resolve/#resolvemodules) search locations with the `resolveModules` key.\n2. All other option keys will become a Webpack [`alias`](https://webpack.js.org/configuration/resolve/#resolvealias).\n\n```javascript\n// gatsby-config.js\nconst path = require(\"path\");\n\nmodule.exports = {\n  plugins: [\n    {\n      resolve: \"gatsby-plugin-root-import\",\n      options: {\n        resolveModules: [path.join(__dirname, \"libs\")],\n        utils: path.join(__dirname, \"src\", \"components\", \"utilities\"),\n      },\n    },\n  ],\n};\n```\n\nThis means you should be able to import modules like such:\n\n```javascript\n// gatsbyProject/libs is now a searched resolve.modules directory\n// importing gatsbybProject/libs/someLib/SomeLibComponent.js\nimport SomeLibComponent from \"someLib/SomeLibComponent\";\n\n// from the 'utils' alias\n// importing gatsbyProject/src/components/utilities/UtilityComponent.js\nimport UtilityComponent from \"utils/UtilityComponent\";\n```\n\n### Jest testing\n\nThe new aliased paths lets Webpack correctly compile your app. However this does not mean that Jest, or other test runners will understand where those aliases point to.\n\nWhen setting up testing with Jest, see [`moduleNameMapper`](https://jestjs.io/docs/en/configuration.html#modulenamemapper-objectstring-string--arraystring) to correctly map your your aliases to a path that Jest can understand.\n\nFor example:\n\n```javascript\n// gatsby-config.js\nconst path = require(\"path\");\n\nmodule.exports = {\n  // ...other configs\n  plugins: [\n    {\n      resolve: \"gatsby-plugin-root-import\",\n      options: {\n        components: path.join(__dirname, \"src\", \"web\", \"components\"),\n      },\n    },\n  ],\n};\n```\n\ncould work with a Jest map like:\n\n```javascript\n// jest.config.js\nmodule.exports = {\n  // ...other configs\n  moduleNameMapper: {\n    \"^components/(.*)\": \"<rootDir>/src/web/components/$1\",\n  },\n};\n```\n\nPlease see Jest's [`moduleNameMapper`](https://jestjs.io/docs/en/configuration.html#modulenamemapper-objectstring-string--arraystring) documentation for specific implementation details regarding format and options.\n\n<details>\n  <summary>Deprecated Gatsby V1 Instructions</summary>\n\n### Install\n\n1. Install the `gatsby-plugin-root-import` plugin:\n\n   `npm install --save-dev --save-exact gatsby-plugin-root-import@1.0.0`\n\n   or\n\n   `yarn add --dev gatsby-plugin-root-import@1.0.0`\n\n### Usage\n\nAdd into `gatsby-config.js`.\n\n```javascript\n// gatsby-config.js\n\nmodule.exports = {\n  plugins: [\"gatsby-plugin-root-import\"],\n};\n```\n\n### Default Settings\n\nIf no options are specified, the plugin defaults to your project root folder.\n\nThis means you should be able to import modules like such:\n\n```javascript\n// importing gatsbyProject/src/yourFolder/YourComponent.js\n\nimport YourComponent from \"src/yourFolder/YourComponent\";\n```\n\n### Plugin Options\n\nYou can pass a `root` option. You can specify your own folder, such as `src`.\nThis option corresponds with Webpack v3's `resolve.root` found [here](https://github.com/webpack/docs/wiki/configuration#resolveroot).\nThis may be both a directory string, or an array of directory strings.\n\n```javascript\n// gatsby-config.js\nconst path = require(\"path\");\n\nmodule.exports = {\n  plugins: [\n    {\n      resolve: \"gatsby-plugin-root-import\",\n      options: {\n        root: path.join(__dirname, \"src\"),\n      },\n    },\n  ],\n};\n```\n\nThis means you can import modules with project's `src` folder as `root`:\n\n```javascript\n// importing gatsbyProject/src/yourFolder/YourComponent.js\n\nimport YourComponent from \"yourFolder/YourComponent\";\n```\n\n</details>\n","publish_time":1534383978134,"_cnpm_publish_time":1534383978134,"dist-tags":{"latest":"2.0.9"}}