gatsby-node.js:
const path = require('path')
exports.onCreateWebpackConfig = ({ actions }) => {
actions.setWebpackConfig({
resolve: {
alias: {
components: path.resolve(__dirname, 'src/components'),
templates: path.resolve(__dirname, 'src/templates'),
},
},
})
};
./project/src/path/to/some/file/of/yours.js:
import Layout from 'components';
as opposed to:
import Layout from '../../../../components/Layout.js';
See GitHub solution as original source and reference.
Top comments (0)