Closed timhaywood closed 2 years ago
Haven't tested it yet 😅 but something like this might work:
// transformIndexHtml() { ...
const tags: HtmlTagDescriptor[] = [
{ tag: "script", children: injectRequire },
{ tag: "script", attrs: { src: `..${jsFileName}` } },
];
if (cssFileNames) {
tags.push(
...cssFileNames.map((file) => ({
tag: "link",
attrs: { rel: "stylesheet", href: `..${file}` },
}))
);
}
if (debugReact) {
tags.push({
tag: "script",
attrs: { src: "http://localhost:8097" },
injectTo: "body",
});
}
return tags;
This implementation seemed to work for my repo, so created a pull request 👍 (But needs a bit more testing I think).
The default index.html
in bolt-cep would also need updating, to add a few things that are missing from the template (e.g. DOCTYPE, lang attribute etc).
Thanks for the help, should be good to go now 👍
So fast! Thanks Justin 🙏
I had some additional script tags in
index.html
for doing things like loading Google Analytics, fonts etc. During dev, vite uses yourindex.html
file in/src
so all works well.On build,
vite-cep-plugin
replaces the html file with the template contents, removing any changes you've done toindex.html
yourself.I should be able to get around this by moving things into the
ts
files — but I wonder if it might be possible to either:Add the needed script/css files to
index.html
without replacing it's contentsLooks like it should be possible to return an array of tags to be added to the existing html, rather than the entire html string?
Callout that your
index.html
is replaced in thebolt-cep
READMEHappy to take a look at modifying the
transformIndexHtml
implementation to see if I can get this working. Thanks!