1
I need to dynamically import paths to Assets from an application, for example:
var cliente = clienteX
import ../../caminho/${cliente}/caminho/arquivo.less
It will not be changed at runtime, it would just pull from a configuration file, which client it will pull the Assets, given that the core of the system is the same.
So I researched the import
is static, so wanted some help or idea of some workaround for this situation.
Edit 1: Example of structure
System
Customers
client 1
- css
- main css.
- css
client 2
- css
- main css.
- css
Example of Imports:
require ('../../Clientes/'+ cliente + '/css/main.css');
import ../../Clientes/${cliente}/css/main.css;
Have you tried using the
require
? If you’re using thebabel
, it has support for therequire
in the browser. Example: https://github.com/pedrolaxe/js-terminal/blob/master/src/js/terminal/commands/index.js#L20– Gabriel Katakura
@Gabrielkatakura I tried too and did not roll very well :/
– user70256
You can try using the
path.resolve
combined with the__dirname
, gives an example of the directory structure to be clearer– Sergio
@Sergio updated the question there
– user70256
The examples you posed was what you tried and didn’t work?
– Sergio
@Sergio that there
– user70256