SmartMirror
SmartMirror copied to clipboard
[discussion] good way to share files among client and server
we currently share the config file among client and server by mirroring it. This won't scale when more files need to shared and there would be lots of moving parts. Need to find a clean way to keep things simple.
- Maybe we can run eject to get hold of webpack, but i'm not sure of other consequences it might have ( maybe none).
need more opinions.
If we do eject, what would we want to do later? https://moduscreate.com/es6-es2015-import-no-relative-path-webpack/ and https://stackoverflow.com/questions/27502608/resolving-require-paths-with-webpack and https://webpack.js.org/configuration/resolve/#resolve-alias
well, I also found this :
- https://medium.com/@ktruong008/absolute-imports-with-create-react-app-4338fbca7e3d
- https://github.com/timoxley/linklocal
I'm yet to test the above . Meanwhile, I'm also testing eject and trying out the links you mentioned.
Awesome! #2 Seems nice and easy, still long path will be necessary thought. It will make some things easier, but all component imports will be very long
-
with linklocal , things will get easier but we'll have to add an extra step to start the project.
-
I also tried creating custom env variables for locales and config paths. But that would mean shifting the dot-dots to
.envfile fromApp.js -
Other method I thought of is to shift the locales and
client.jsinsideclientfolder. Sure, it includes changes to server-side code but seems straightforward ( and can keep things simple for future? ).
What do you think ?
Just found this: https://www.npmjs.com/package/clientconfig Looks like exactly what we want?
Not sure how it can be used with react app . what do you have in mind ? On 06/10/2017 3:05 pm, "Jakob Krantz" [email protected] wrote:
Just found this: https://www.npmjs.com/package/clientconfig Looks like exactly what we want?
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/jakkra/SmartMirror/issues/43#issuecomment-334707157, or mute the thread https://github.com/notifications/unsubscribe-auth/AGdNPnR0DpOxlyN7NqtZECUSfiPIzge2ks5spfRQgaJpZM4Put37 .
I didn't think of any problem because of react app. Server side it just sends the config as a cookie, which can be retrieved client side. Maybe I miss something, couldn't it just be required in react as usual?
I'll give it a test to have config as a cookie, otherwise we'll go with your proposal 2 or 3 :)
Sorry I got a little busy. Yeah, go for it . would be great if that works :) On 06/10/2017 10:50 pm, "Jakob Krantz" [email protected] wrote:
I'll give it a test to have config as a cookie, otherwise we'll go with your proposal 2 or 3 :)
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/jakkra/SmartMirror/issues/43#issuecomment-334817357, or mute the thread https://github.com/notifications/unsubscribe-auth/AGdNPi6SomR7NX2y_HoyI1LRrVCu_QYTks5spmFLgaJpZM4Put37 .
Couldn't get clientconfig to work server side, since react-create-app uses webpack proxy. Didn't manage to send the cookie.
hey, so what's the next step ?
As I undertsand with .env the imports client side will need to be client/src/compoment/Clock.js?
And to import the config it would be just config, since it's in the root directory?
I don't like that the client/src part is necessary, however I really like the idea of not having relative import paths. So I think the pros are greater than the cons :)
Hey, I tried .env approach. Here's what i did :
- bump react-scripts version from
0.7.0to1.0.0to support settingNODE_PATH - I set
NODE_PATH=src/in.envin the client directory - was able to import components like
components/<Component>.js - The problem is this :

Turns out it CRA guys dont' allow any other files outside of the NODE_PATH ( once you set it)
Here's a discussion
Have a look and let me know if I missed something. :)
Okey, thanks for looking into it. Maybe we can just move them into source?
Or there is probably a correct way to have pictures. Like some kind of asset folder. Could look up how it should be done in create react app. I'm a little busy, but hopefully next week I have time to check it out :)