Skip to content

How to configure a webpack alias  #877

@thisbejim

Description

@thisbejim

I'd like to configure some webpack aliases to point to some of my folders (not to a lib in node_modules).

Here is a simple example:

var path = require('path');

module.exports = {
  webpack: function (config) {
    config.resolve.alias = {
      'components': path.resolve('./components'),
    };
    return config
  }
}

However, if I try to import a component in a page e.g:

import { NavBar } from 'components';

I get the following error:Error: Cannot find module 'components'

Any idea how to get next to play nice with an alias like this?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions