Description
What is the current behaviour?
Currently, source files map to build artefacts as following:
- src/template.html -> /index.html
- src/manifest.json -> /manifest.json
- src/.(js|css) -> /bundleZZZ.
- src/assets/** -> /assets/
- src/assets/favicon.ico -> /favicon.ico (in addition to /assets)
- src/static/** -> / (ex. robots.txt)
What is the motivation or use case for changing this behaviour?
'assets' was created by 'simple' template. OK.
Then I found I need 'static' for robots.txt. #436.
Then I found I need regexes for caching rules. #1364.
Now, when adding/looking for an asset I have to recollect the difference between 'assets' and 'static'. #1611
If I try to simplify and use 'static' instead of 'assets', favicon link is not added to the html.
If I put manifest.json to 'static', title is not expanded properly in the html.
Even if I fix favicon and title in the html manually, 'assets' is still required (with at least one file).
So, we need to use all 'assets' and 'static' and '/' and remember what goes where.
Describe the solution you'd like
Can these 6 rules be simplified to 2?
- public/** -> / (including index.html, manifest.json, favicon.ico, robots.txt)
- src/.(js|css) -> /static/bundleZZZ. (to be able to cache the whole 'static' folder agressively)
Please mention any other relevant information.
This is how create-react-app does it.
As a lot of devs come from there, it could be beneficial to match.
Above points are rather minor, and could possibly be resolved by re-configuration.
But absence of good defaults kills otherwise "streamlined" feeling.
Especially after using create-react-app where it all "just works".
Please paste the results of npx preact-cli info
here.
System:
OS: Windows 10 10.0.19043
CPU: (8) x64 Intel(R) Core(TM) i5-8250U CPU @ 1.60GHz
Binaries:
Node: 16.13.2 - C:\Program Files\nodejs\node.EXE
Yarn: 1.22.15 - C:\Program Files\nodejs\yarn.CMD
npm: 7.19.0 - C:\Program Files\nodejs\npm.CMD
Browsers:
Chrome: 99.0.4844.51
Edge: Spartan (44.19041.1266.0), Chromium (99.0.1150.36)
npmPackages:
preact: ^10.1.0 => 10.6.6
preact-cli: ^3.0.0 => 3.3.5
preact-render-to-string: ^5.1.2 => 5.1.20
Activity