I'm using webpack, babel and react.
I have imports all throughout my react project that look something like
import Slideshow from './Slideshow.js'
I have multiple react projects that use the exact same component, so rather than have multiple versions of the same file I'm trying to move my standard components that I reuse into a standard directory such as
~/StandardComponents/Slideshow.js
To reduce the amount of places I would have to edit my code if this directory changes I would like to create a variable and import my modules like this
const standard = '~/StandardComponents'
import Slideshow from standard + '/Slideshow.js'
It looks like one option is maybe setting my node_path within package.json?
I don't really know anything about this, but I attempted it by changing my package.json from
"scripts": {
"start": "webpack-dev-server --inline",
"build": "webpack"
}
"scripts": {
"dev": "NODE_PATH=./:/Users/Sam/Documents/Projects_and_Code/Code_Projects/Standard",
"start": "webpack-dev-server --inline",
"build": "webpack"
}
Some other solutions I looked at didn't really provide enough detail for me. The correct solution on this question is
System.import('./utils/' + variableName).then(function(m) {
console.log(m);
});
And I don't really know what the 'then' is about, nor the function inside the then and why they have console.log(m) in there (I'm guessing the console.log(m) is just an example of some basic code, but why? What is it an example for?)
I'd very much prefer a solution that just adds something to my webpack.config.js, or package.json that is something like
SearchOnPath: 'currentDir:~/Standards'
or
Standards = '~/Standards'