Categories: A TestNode.js

Import from subfolder of npm package

const path = require('path');

module.exports = {
'@components': path.resolve(__dirname, 'node_modules/components-library/src'),
'@another': path.resolve(__dirname, 'node_modules/any/path/you/want'),
}
const appAliases = require('app-aliases');

const config = {
...
  resolve: {
    alias: {
      ...appAlises
    }
  }
}
import {Button} from '@components/Button';
import {Something} from '@another'
  1. Yes, you can use any path in aliases
  2. Yes, it is not necessary to build all of your projects
  3. I see that now mui uses imports from directi packages (core for example), see https://material-ui.com/components/radio-buttons/ there is import Radio from '@material-ui/core/Radio';. But I hope they using re-export that I described below.
Source: stackoverflow.com
admin

Recent Posts

React: How do I use values from an object’s specific key?

I am new to React and am trying to figure out how to return a…

19 hours ago

How to check all links in cypress without stopping in case of an error

So basicly I have to test many many links on many many sites so I…

2 days ago

why this navigation bar not changing its background on hover

I'm learning JS, I know I can do this in CSS, but I want to…

2 days ago

javascript/typescript – force to pass object as function argument by eslint rule

Is it possible to force the following rule by eslint? if the number of function…

2 days ago

Having trouble returning a promise and then consuming it after a database call

Im learning Javascript and im up to a section on Promises. So decided to try…

2 days ago

ReactJS Add to Object that is a State

hoping this is a simple answer but it's racking my brain. Let's say I have…

2 days ago

This website uses cookies.