question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to build preact in one index.html file?

See original GitHub issue

Hey. I use preact to create interactive pages that are hosted in the memory of the microcontroller. The preact size and features are really impressive, but for my use case it is still overloaded.

What can I do so that when I run the npm run build command, I get 1 file - index.html, where will all the styles and scripts be inside?

I used to have a working version, but when updating webpack and preact, it turned out to be not working:

package.json "build": "preact build --no-prerender --no-service-worker"

preact.config.js

export default (config, env, helpers) => {
    const chunks = helpers.getPluginsByName(config, 'CommonsChunkPlugin')[0]
    config.plugins[chunks.index].minChunks = 1
}

Thanks!

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:28 (12 by maintainers)

github_iconTop GitHub Comments

3reactions
sebasjmcommented, Jun 29, 2021

I made this but it was not so easy as a one liner

https://gist.github.com/sebasjm/087df4b0b0a611ce409fe30a67a1d0d9

Any improvement would be greatly appreciated.

3reactions
bseckercommented, Jun 17, 2020

Hey @BRAGA96 did you end up making any progress with this? I am in the exact situation using a microcontroller, and am also interested in condensing the build files into a single html file

Read more comments on GitHub >

github_iconTop Results From Across the Web

Getting Started | Preact: Fast 3kb React alternative with the ...
For most templates, the best place to start is src/index.js or src/components/app/index.js . Production builds. The npm run build command compiles a production ......
Read more >
Preact CLI How To Access Index Page - Stack Overflow
I have created an app using the preact- ...
Read more >
Building a Form with Preact | www.thecodebarbarian.com
First, let's set up a basic index.html file that will serve as the entry point for the app. <html> <head> <title>Preact Test</title> </head> ......
Read more >
Getting Started - Vite
A build command that bundles your code with Rollup, pre-configured to output ... One thing you may have noticed is that in a...
Read more >
Embeddable Web Applications with Shadow DOM - Viget
Let's build an embeddable Preact web app using the Shadow DOM. ... a src directory and a few files: index.html , index.tsx ,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found