From 72dc200bacae00e538615e1a342b0c5291bd1ecf Mon Sep 17 00:00:00 2001 From: ajayns Date: Mon, 11 Feb 2019 22:49:58 +0530 Subject: [PATCH 1/2] Add gatsby-plugin-alias-imports --- package.json | 1 + yarn.lock | 14 ++++++++++++++ 2 files changed, 15 insertions(+) diff --git a/package.json b/package.json index fbd5e474..4db64020 100644 --- a/package.json +++ b/package.json @@ -10,6 +10,7 @@ "formik": "^1.4.1", "gatsby": "^2.0.53", "gatsby-image": "^2.0.20", + "gatsby-plugin-alias-imports": "^1.0.5", "gatsby-plugin-canonical-urls": "^2.0.8", "gatsby-plugin-favicon": "^3.1.5", "gatsby-plugin-google-analytics": "^2.0.8", diff --git a/yarn.lock b/yarn.lock index 79eae385..ef2e6c21 100644 --- a/yarn.lock +++ b/yarn.lock @@ -716,6 +716,13 @@ dependencies: regenerator-runtime "^0.12.0" +"@babel/runtime@^7.2.0": + version "7.3.1" + resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.3.1.tgz#574b03e8e8a9898eaf4a872a92ea20b7846f6f2a" + integrity sha512-7jGW8ppV0ant637pIqAcFfQDDH1orEPGJb8aXfUozuCU3QqX7rX4DA8iwrbPrR1hcH0FTTHz47yQnk+bl5xHQA== + dependencies: + regenerator-runtime "^0.12.0" + "@babel/template@7.0.0-beta.44": version "7.0.0-beta.44" resolved "https://registry.yarnpkg.com/@babel/template/-/template-7.0.0-beta.44.tgz#f8832f4fdcee5d59bf515e595fc5106c529b394f" @@ -5668,6 +5675,13 @@ gatsby-link@^2.0.7: "@types/reach__router" "^1.0.0" prop-types "^15.6.1" +gatsby-plugin-alias-imports@^1.0.5: + version "1.0.5" + resolved "https://registry.yarnpkg.com/gatsby-plugin-alias-imports/-/gatsby-plugin-alias-imports-1.0.5.tgz#44c0856d77acb74b58b89ec725dadd8f5d5b327d" + integrity sha512-q58JrSjuVNh4NApamqElR0zqwm55FOb9vFAVb2i2ftPRu0uYzWJkbOz2IN3vSw7a+5PmGzX7VL8XDFXlNHrMNA== + dependencies: + "@babel/runtime" "^7.2.0" + gatsby-plugin-canonical-urls@^2.0.8: version "2.0.8" resolved "https://registry.yarnpkg.com/gatsby-plugin-canonical-urls/-/gatsby-plugin-canonical-urls-2.0.8.tgz#cea25698fc6066ec3984047d46f4f8c1b55b3d65" From 636951ac085860b8c87c1226b005f87f915e33b1 Mon Sep 17 00:00:00 2001 From: ajayns Date: Mon, 11 Feb 2019 22:50:09 +0530 Subject: [PATCH 2/2] Configure gatsby-plugin-alias-imports --- gatsby-config.js | 17 +++++++++++++++-- gatsby-node.js | 13 ------------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/gatsby-config.js b/gatsby-config.js index 37e83f35..4dec3687 100644 --- a/gatsby-config.js +++ b/gatsby-config.js @@ -1,3 +1,4 @@ +const path = require('path') const config = require('./data/config') require('dotenv').config({ @@ -45,8 +46,8 @@ module.exports = { resolve: 'gatsby-plugin-google-analytics', options: { trackingId: config.googleAnalyticsID, - head: true - } + head: true, + }, }, { resolve: 'gatsby-plugin-favicon', @@ -79,5 +80,17 @@ module.exports = { }, }, 'gatsby-plugin-offline', + { + resolve: `gatsby-plugin-alias-imports`, + options: { + alias: { + Components: path.resolve(__dirname, 'src/components'), + Common: path.resolve(__dirname, 'src/components/common'), + Static: path.resolve(__dirname, 'static/'), + Theme: path.resolve(__dirname, 'src/components/theme'), + Data: path.resolve(__dirname, 'data/config'), + }, + }, + }, ], } diff --git a/gatsby-node.js b/gatsby-node.js index f35c4aff..e69de29b 100644 --- a/gatsby-node.js +++ b/gatsby-node.js @@ -1,13 +0,0 @@ -exports.onCreateWebpackConfig = ({ actions }) => { - actions.setWebpackConfig({ - resolve: { - alias: { - Components: `${__dirname}/src/components`, - Common: `${__dirname}/src/components/common`, - Static: `${__dirname}/static/`, - Theme: `${__dirname}/src/components/theme`, - Data: `${__dirname}/data/config`, - }, - }, - }) -}