-
-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement Webpack "resolve aliases" for project source paths
See GH-26 for details about the structure concept. References: https://webpack.js.org/configuration/resolve/#resolve-alias GH-31
- Loading branch information
1 parent
b18dfdb
commit 187237a
Showing
3 changed files
with
59 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,7 +12,6 @@ | |
* Allows to let plugins extend/mutate the project's Babel configuration. | ||
* @author Arctic Ice Studio <[email protected]> | ||
* @author Sven Greb <[email protected]> | ||
* @see https://gatsbyjs.org/docs/node-apis/#onCreateBabelConfig | ||
* @see https://babeljs.io | ||
* @since 0.1.0 | ||
*/ | ||
|
@@ -21,7 +20,8 @@ | |
* Implementation of the Gatsby Node `onCreateBabelConfig` API. | ||
* | ||
* @method onCreateBabelConfig | ||
* @param {object} actions Collection functions provided by Gatsby used to manipulate the state of the build process. | ||
* @param {object} actions Collection of functions provided by Gatsby used to manipulate the state of the build | ||
* process. | ||
* @see https://gatsbyjs.org/docs/node-apis/#onCreateBabelConfig | ||
* @see https://gatsbyjs.org/docs/actions | ||
* @since 0.1.0 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/* | ||
* Copyright (C) 2018-present Arctic Ice Studio <[email protected]> | ||
* Copyright (C) 2018-present Sven Greb <[email protected]> | ||
* | ||
* Project: Nord Docs | ||
* Repository: https://github.com/arcticicestudio/nord-docs | ||
* License: MIT | ||
*/ | ||
|
||
/** | ||
* @file Implementation of Gatsby Node `onCreateWebpackConfig` API. | ||
* Allows to let plugins extend/mutate the project's webpack configuration. | ||
* @author Arctic Ice Studio <[email protected]> | ||
* @author Sven Greb <[email protected]> | ||
* @see https://webpack.js.org | ||
* @since 0.1.0 | ||
*/ | ||
|
||
const { resolve: resolvePath } = require("path"); | ||
|
||
const r = m => resolvePath(__dirname, m); | ||
|
||
/** | ||
* Implementation of the Gatsby Node `onCreateWebpackConfig` API. | ||
* | ||
* @method onCreateWebpackConfig | ||
* @param {object} actions Collection of functions provided by Gatsby used to manipulate the state of the build | ||
* process. | ||
* @see https://gatsbyjs.org/docs/node-apis/#onCreateWebpackConfig | ||
* @see https://gatsbyjs.org/docs/actions/#setWebpackConfig | ||
* @since 0.1.0 | ||
*/ | ||
const onCreateWebpackConfig = ({ actions }) => { | ||
actions.setWebpackConfig({ | ||
resolve: { | ||
alias: { | ||
assets: r("../src/assets/"), | ||
atoms: r("../src/components/atoms/"), | ||
config: r("../src/config/"), | ||
containers: r("../src/components/containers/"), | ||
data: r("../src/data/"), | ||
layouts: r("../src/components/layouts/"), | ||
molecules: r("../src/components/molecules/"), | ||
organisms: r("../src/components/organisms/"), | ||
pages: r("../src/components/pages/"), | ||
stores: r("../src/stores/"), | ||
styles: r("../src/styles/"), | ||
templates: r("../src/components/templates/"), | ||
utils: r("../src/utils/") | ||
} | ||
} | ||
}); | ||
}; | ||
|
||
module.exports = onCreateWebpackConfig; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,8 @@ | |
* @author Arctic Ice Studio <[email protected]> | ||
* @author Sven Greb <[email protected]> | ||
* @see https://gatsbyjs.org/docs/node-apis | ||
* @since 0.1.0 | ||
*/ | ||
|
||
exports.onCreateBabelConfig = require("./.gatsby/onCreateBabelConfig"); | ||
exports.onCreateWebpackConfig = require("./.gatsby/onCreateWebpackConfig"); |