Is it possible to provide the main
field of a canister in dfx.json
with a directory up path?
Such as for example:
{
"canisters": {
"yolo": {
"main": "../backend/yolo.mo", // <- here ../
"type": "motoko"
},
We’ve got a mono-repo (with no scripts at its root). I was asking myself if it would be possible move the backend code “outside” of the (frontend) app.
Might be useful if same canisters would be used across projects of the mono-repo.
./
./app1/package.json
./app1/dfx.json
./app2/package.json
./app2/dfx.json
./backend/yolo
To answer my own question, no parent path are not supported.
If I use as displayed above "../backend/yolo.mo"
or absolute path in my dfx.json
configuration, I get errors such as:
The post-build step failed for canister ‘…’ with an embedded error: Directory at ‘…’ is outside the workspace root.
That being said, there might be anyway a solution for my use case with a monorepo by moving the dfx.json
configuration to the parent or top folder. Doing so I can have the frontend app(s) in different folders and the canisters separated.
./app/package.json
./app/src/index.html
./backend/src/counter.mo
./dfx.json
It needs some modifications in dfx.json
and in the webpack.config
but, that seems duable.
I’ve put together a sample / starter repo, seems alright at least when run on a a local ic.
1 Like