Skip to content

[QUESTION] Integration with Vite #2

Open
@go4cas

Description

Hi @stephancasas. So, my boilerplate with the component based structure is coming on nicely. I have, however, decided to swap out rollup with Vite, for build and bundling. Everything works really well. I just want some advice on one item, when including presto in my build chain.

Vite relies on the index.html file as its starting point. So, before adding presto to my app, the build would basically do the following:

  • Scan index.html from the src folder
  • Change relative paths for assets, etc in this file
  • Work through index.js in the src folder, which is embed in the index.html file, and does all the js imports, bundling, etc, etc
  • Then copy over the final bundle (including the changed index.html) to the list folder

All of this works 100%.

Now, when including presto in my project, I will have a situation whereby both presto and vite need to make changes to the index.html. The only way I can see around this is:

  • Create a new "main" html file in src (example app.html)
  • Then change my presto.config.js to look something like this:
export default {
  input: 'src/app.html',
  output: {
    file: 'src/index.html',
    formatting: 'none'
  }
}
  • My build commands will then be:
"build:markup": "presto --config presto.config.js",
"build:bundle": "vite build",
"build": "npm-run-all build:markup build:bundle"
  • The theory is that presto will do its magic, and then create the index.html that vite will use to build and bundle

Does this make sense? Can you think of an easier/better way to achieve this?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

Labels

questionFurther information is requested

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions