|
| 1 | +/* |
| 2 | + * Copyright (C) 2018-present Arctic Ice Studio <[email protected]> |
| 3 | + * Copyright (C) 2018-present Sven Greb <[email protected]> |
| 4 | + * |
| 5 | + * Project: Nord Docs |
| 6 | + * Repository: https://github.com/arcticicestudio/nord-docs |
| 7 | + * License: MIT |
| 8 | + */ |
| 9 | + |
| 10 | +/** |
| 11 | + * @file Implementation of Gatsby Node `onCreateWebpackConfig` API. |
| 12 | + * Allows to let plugins extend/mutate the project's webpack configuration. |
| 13 | + * @author Arctic Ice Studio <[email protected]> |
| 14 | + * @author Sven Greb <[email protected]> |
| 15 | + * @see https://webpack.js.org |
| 16 | + * @since 0.1.0 |
| 17 | + */ |
| 18 | + |
| 19 | +const { resolve: resolvePath } = require("path"); |
| 20 | + |
| 21 | +const r = m => resolvePath(__dirname, m); |
| 22 | + |
| 23 | +/** |
| 24 | + * Implementation of the Gatsby Node `onCreateWebpackConfig` API. |
| 25 | + * |
| 26 | + * @method onCreateWebpackConfig |
| 27 | + * @param {object} actions Collection of functions provided by Gatsby used to manipulate the state of the build |
| 28 | + * process. |
| 29 | + * @see https://gatsbyjs.org/docs/node-apis/#onCreateWebpackConfig |
| 30 | + * @see https://gatsbyjs.org/docs/actions/#setWebpackConfig |
| 31 | + * @since 0.1.0 |
| 32 | + */ |
| 33 | +const onCreateWebpackConfig = ({ actions }) => { |
| 34 | + actions.setWebpackConfig({ |
| 35 | + resolve: { |
| 36 | + alias: { |
| 37 | + assets: r("../src/assets/"), |
| 38 | + atoms: r("../src/components/atoms/"), |
| 39 | + config: r("../src/config/"), |
| 40 | + containers: r("../src/components/containers/"), |
| 41 | + data: r("../src/data/"), |
| 42 | + layouts: r("../src/components/layouts/"), |
| 43 | + molecules: r("../src/components/molecules/"), |
| 44 | + organisms: r("../src/components/organisms/"), |
| 45 | + pages: r("../src/components/pages/"), |
| 46 | + stores: r("../src/stores/"), |
| 47 | + styles: r("../src/styles/"), |
| 48 | + templates: r("../src/components/templates/"), |
| 49 | + utils: r("../src/utils/") |
| 50 | + } |
| 51 | + } |
| 52 | + }); |
| 53 | +}; |
| 54 | + |
| 55 | +module.exports = onCreateWebpackConfig; |
0 commit comments