Comments (7)
I cannot reproduce from the provided repo. It seemingly builds just fine? As far as I can see you don't even use the one route? Please double check that reproduction.
I should point out that your app breaks hooks; you cannot call hooks conditionally, in React or Preact. This is one of their intrinsic rules. Things like this will break your app:
if (typeof window !== 'undefined') {
mobile = useMediaQuery('(max-width: 520px)');
}
from preact-cli.
I am very sorry @rschristian I sent you wrong index.js file, I fixed it and removed all conditional hook calls even for translation to further simplify testing, but every thing works fine when not route importing, and in both cases no errors are produced during dev or build, it happens when I upload the static build to the host (hostinger), I will include two links for both cases .
Route import ( produces issue ): https://dev8.bdoonwasyt.com/
Normal import ( works fine ): https://dev9.bdoonwasyt.com/
thanks in advance!
from preact-cli.
Have you tested using the serve
command locally? That will spin up a server to test the output of the build
command.
There's nothing I can do to help you with that deployed site. I need source code.
from preact-cli.
Have you tested using the
serve
command locally? That will spin up a server to test the output of thebuild
command.There's nothing I can do to help you with that deployed site. I need source code.
serve logs the same error
route_splitting_issue.zip
from preact-cli.
You still have conditional hooks:
// routes/login/index.js
if (typeof window !== "undefined") {
form = useForm({
...
});
}
This fundamentally isn't allowed in React or Preact and it will completely break hooks in your app. You can read more here.
Your provided app does not build out-of-the-box, it's seemingly missing dependencies, and iss all of that i18n
stuff needed? Those dependencies cause a dead-lock on the build process, something's not configured right.
from preact-cli.
I should also mention that you probably should look to use Vite, not Preact-CLI, for your Preact apps. We haven't been able to maintain this as much as we'd like and Webpack hasn't kept up well.
We have a Vite initializer which you can use by running npm init preact
, it'll give you a few options before setting up your new project.
from preact-cli.
Closing, hopefully its been addressed.
from preact-cli.
Related Issues (20)
- compiling✖ ERROR Error: Babel-loader config not found!!! HOT 9
- Pages duplicate when accessing with /index.html HOT 9
- Brotli build - outputs content to same filename HOT 4
- default project template doesn't work with Node v18 HOT 4
- ERROR Error: error:0308010C:digital envelope routines::unsupported HOT 1
- Duplicated content when using /routes when using CLI v4 HOT 5
- Homepage content loaded on all non-prerendered pages HOT 3
- Add Typescript increasses the bundle size HOT 4
- Can't resolve 'preact-cli-entrypoint' HOT 4
- Exported rest param syntax functions create invalid build JS HOT 4
- preact-cli hangs after "✔ Done!" HOT 5
- CSS source maps missing in build output HOT 3
- Typescript v5.1.6 compatibility HOT 2
- Route code-splitting breaks lazy loading of images HOT 3
- Use esbuild instead of babel HOT 2
- Fail to build due to `property missing ':'` when inline style HOT 4
- OptimizeCssAssetsPlugin causes build to crash in Yarn PnP mode HOT 2
- Config file failure when adding plugins HOT 8
- build gets stuck at "after chunk asset optimization" HOT 11
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 preact-cli.