Comments (2)
OK, this is a straight-up bug. I've never considered the impact of PUBLIC_URL
in @fab/input-static
. What's weird to me is how rc6 ever worked!?
It feels like the CRA build must be different between your two apps: as far as I remember @fab/input-static
will faithfully capture whatever is in the dir
argument. Can you run tree dist
(assuming dist
is your output directory) in both projects? Maybe CRA is actually writing everything to /plugin/
in your first app.
I don't have a clear solution here, you're basically wanting to "mount" the whole FAB at a subpath, right? Or do you feel like everything in the FAB should be prefixed with plugin
?
If we go the first route, we could add an argument like fab serve --base="/plugin"
, so the FAB doesn't actually know what path it lives under, that's the server's job.
Alternatively, we could add a flag of @fab/input-static
, effectively "mounting" the dist
dir at a subpath within the FAB. Then it gets served at /
but has /plugin
routes internally, much like what you already have.
As a stop gap, you could add a step to your build to move your dist
directory around to create the directory structure with plugin
in it. Something like:
"build:fab": "npm run build && rm -rf .build && mkdir -p .build/plugin && cp -R dist/* .build/plugin"
{
plugins: {
"@fab/input-static": {
dir: "./build"
}
}
// ...
}
Bit clunky, but might get you over the immediate problem while we figure out the "right" approach.
from fab.
Alright I got it!
So it's indeed unrelated to rc6 vs rc9, actually there was a key difference between the build of the two apps that your thinking got me to find out (huge thanks! 🥇 ).
I wouldn't say it's literally a FAB bug, because CRA actually gives us all the power needed to get this to work nicely together, so maybe what I'm sharing here can serve as a basis for future documentation.
The key aspect is indeed in the directory structure of the build/
output of CRA. In my working plugin
app, this is overridden to be build/plugin/
and this is what makes it work (but I didn't notice it at first because it was overridden in a hacky, hidden way). Doing the same thing for my kyb
app makes it work too.
So what's needed for this to work is the following in .env
for CRA:
# Makes assets relative to subpath:
PUBLIC_URL=/kyb/
# Makes the FAB pick up the subpath to rewrite the assets path:
BUILD_PATH=./build/kyb/
(what I was missing was the BUILD_PATH
variable, it's documented on the CRA website)
And in the fab.config.json5
:
{
plugins: {
'@fab/input-static': {
dir: './build',
},
'@fab/plugin-render-html': {
fallback: '/kyb/index.html',
},
'@fab/plugin-rewire-assets': {},
},
settings: {
// ...
},
deploy: {
// ...
},
}
Now I'm realising that I didn't explained why I was trying to do that:
- We use a custom domain locally and have nginx as a reverse proxy to route traffic to different React apps based on subpaths of that domain (so
http://domain.local/plugin
goes to theplugin
React app andhttp://domain.local/kyb
goes to thekyb
React app). In that context, we use CRA in watch mode, we don't run the actual FAB (so we can have HMR & all, related to #345 actually) - On production there is no nginx reverse proxy either, we use Cloudflare Workers and route those subpaths to different workers (one per app) serving the FABs
I hope this is clear enough! Thanks for your help and let me know if you would like me to share more details :) (otherwise you can close this I think)
from fab.
Related Issues (20)
- Nextjs userbase auth , fab deployment error
- Build issue: Node's own modules are being transpiled, which results in a broken build HOT 3
- Next.js build failing with final_responder plugin error HOT 4
- Preact bundling error HOT 1
- after first load not work nextjs api on cloudflare workers HOT 2
- FAB Next.js build doesn't respect Next Build Configuration HOT 5
- Difference in behaviour locally vs AWS for server side relative redirects to public files
- Yarn Berry - missing transitive deps on init HOT 1
- Docs for how to monitor the resulting production app
- Issue with serve for a Nextjs project HOT 1
- NextJS static pages with dynamic routes results in oversized server.js HOT 15
- webpack-bundle-analyzer to debug FAB size? HOT 7
- Flareact Consideration HOT 2
- Typescript Error for resolve() HOT 1
- TypeScript: Support for typechecking the `settings` object HOT 1
- Can we make HERE_NO_EVAL CF specific?
- Set-Cookie not respected in redirects HOT 4
- next12 HOT 1
- Is this project dead?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fab.