diff --git a/.gatsby/onCreateBabelConfig.js b/.gatsby/onCreateBabelConfig.js index c8d6c80f..0f584bc5 100644 --- a/.gatsby/onCreateBabelConfig.js +++ b/.gatsby/onCreateBabelConfig.js @@ -12,7 +12,6 @@ * Allows to let plugins extend/mutate the project's Babel configuration. * @author Arctic Ice Studio * @author Sven Greb - * @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 diff --git a/.gatsby/onCreateWebpackConfig.js b/.gatsby/onCreateWebpackConfig.js new file mode 100644 index 00000000..d0fc90dd --- /dev/null +++ b/.gatsby/onCreateWebpackConfig.js @@ -0,0 +1,55 @@ +/* + * Copyright (C) 2018-present Arctic Ice Studio + * Copyright (C) 2018-present Sven Greb + * + * 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 + * @author Sven Greb + * @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; diff --git a/gatsby-node.js b/gatsby-node.js index d50ffd7f..0aaac3fd 100644 --- a/gatsby-node.js +++ b/gatsby-node.js @@ -12,6 +12,8 @@ * @author Arctic Ice Studio * @author Sven Greb * @see https://gatsbyjs.org/docs/node-apis + * @since 0.1.0 */ exports.onCreateBabelConfig = require("./.gatsby/onCreateBabelConfig"); +exports.onCreateWebpackConfig = require("./.gatsby/onCreateWebpackConfig");