Do you want to request a _feature_ or report a _bug_?
feature
What is the current behaviour?
The rendered index.html has references to the generated JS and CSS files prefixed with /, meaning you can't run the app from a directory, say.
If the current behaviour is a bug, please provide the steps to reproduce.
$ preact create typescript my-project
$ npm run build
What is the expected behaviour?
The generated src tags are relative to the index.html
If this is a feature request, what is motivation or use case for changing the behaviour?
I want to run my Preact app in a subfolder.
Please mention other relevant information.
I can find there is an EJS template at src/template.html, but it is completely opaque how preact.headEnd would be filled. I would like
Please paste the results of preact info here.
Environment Info:
System:
OS: Linux 5.4 Ubuntu 20.10 (Groovy Gorilla)
CPU: (16) x64 AMD Ryzen 7 3700X 8-Core Processor
Binaries:
Node: 12.16.1 - ~/.nvm/versions/node/v12.16.1/bin/node
npm: 6.14.6 - ~/.nvm/versions/node/v12.16.1/bin/npm
Browsers:
Firefox: 84.0
npmPackages:
preact: ^10.3.1 => 10.5.7
preact-cli: ^3.0.0 => 3.0.5
preact-render-to-string: ^5.1.4 => 5.1.12
preact-router: ^3.2.1 => 3.2.1
npmGlobalPackages:
preact-cli: 3.0.5
Set the publicPath in your preact.config.js with something like:
export default {
webpack(config, env, helpers) {
if (env.production) {
config.output.publicPath = 'https://rschristian.github.io/preact-hint';
}
},
};
Just an example taken from an existing project of mine. Its serves from the subdir as it's on GH pages
Thank you. I heard Jason Miller say in a podcast he would like preact-cli to be build tool agnostic - I guess this is an issue common to make an CLI option out of?
Also, this doesn't seem to work.
I get a 404 to /route-notfound.chunk.c3378.css
Not sure where you heard "build tool agnostic" from, CLI is very much attached to Webpack.
I guess this is an issue common to make an CLI option out of?
IMO we already have way too many CLI options. I'd say no, personally.
Where are you seeing that error? Have you deployed it to the server? That's not going to work locally.
I was working with an old cache, I think. I redeployed and it works now. Thank you!
(By the way, I heard it on Modern Web S07E13 from November 25. I probably misremember what he said exactly.)
Hmm you might be thinking of WMR, though I'm not sure I'd call it "build tool agnostic". Might take a listen myself. Thanks for the info! Certainly let me know if I can help with anything else.
Oh, that's it! I have trouble understanding how WMR relates to preact-cli. Is it meant as a replacement? Different use case?
Not replacement, not yet. WMR (from what I understand, I'm certainly not Jason) was built first and foremost as a great prototyping tool, and then all the standard, long-term project stuff was added on top with a few cool twists. It's young though, and largely untested while the CLI is a behemoth of a Webpack config that is more of a standard.
@digitalheir Now I think I understand, I believe Jason was saying WMR is framework/library agnostic, not build tool agnostic. You don't have to use Preact with it. People got it working with Angular rather quickly and I think others were trying Svelte and Vue. That makes the most sense to me, though I'll still have a listen.
Most helpful comment
@digitalheir Now I think I understand, I believe Jason was saying WMR is framework/library agnostic, not build tool agnostic. You don't have to use Preact with it. People got it working with Angular rather quickly and I think others were trying Svelte and Vue. That makes the most sense to me, though I'll still have a listen.