Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Alias support #139

Open
subhendukundu opened this issue Feb 26, 2021 · 2 comments
Open

Alias support #139

subhendukundu opened this issue Feb 26, 2021 · 2 comments
Labels
enhancement New feature or request

Comments

@subhendukundu
Copy link
Contributor

Describe the problem:

Webpack alias support is not working as it's not implemented yet.
Is there a plan to add it?

import Utility from '../../utilities/utility';
// can be written as  with alias
import Utility from 'Utilities/utility';

There are two ways to achieve it. One adding jsconfig.js or jscong.ts which nextjs does.
https://nextjs.org/docs/advanced-features/module-path-aliases

Or using flareact.config.js using resolve: {alias: {} I have added for this one
subhendukundu@57d6e19

Please let me know if you would prefer both ways, I can create a PR.

@tj-kev
Copy link
Contributor

tj-kev commented Apr 15, 2021

This would be great thing to add.

@tj-kev tj-kev added the enhancement New feature or request label Apr 19, 2021
@Kelin2025
Copy link

Kelin2025 commented Oct 25, 2021

You can just modify your webpack config
For example, I have @ alias that maps to src folder

const path = require('path');

module.exports = {
  webpack: (config, { dev, isWorker, defaultLoaders, webpack }) => {
    config.resolve.alias = {...(config.resolve.alias || {})}
    config.resolve.alias['@'] = path.resolve(__dirname, 'src')

    return config;
  },
};

And, if you're using TypeScript, don't forget about tsconfig.json:

{
  "compilerOptions": {
    "paths": {
      "@/*": ["./src/*"]
    }
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants