Transfer a file, then inline it without Webpack bundling/loader code
Asked Answered
F

0

6

I cannot come up with a working solution. I guess I should somehow be using html-webpack-inline-source-plugin or a combination of multiple entry points but this is too much for me to handle.

What I want to have is:

  • all my js files bundled together and injected (not inlined) into index.html [this works of course!]
  • one js file, which is not included in the bundle described above, inlined into index.html
  • the inlined js file has to go through the Webpack "transformation pipe" since that js file depends on the Webpack build step

Example of the file to be inlined:

const asset = "require('./assets/blob.json')";
fetch(asset).then(.......)

This file should first go through the Webpack transformation since what should actually be inlined is something like:

<script>    
  var asset = "/static/json/blob.md5hashofblobjson.json";
  fetch(asset).then(.......)
</script>

So basically the file that is to be inlined depends on the Webpack build process and cannot be just read with the fs module and written directly into index.html by hand.

Also, the inlined JavaScript should not include any WebpackJSONP bundle loading code, just the pure JS. Below that inlined piece of JS should come the usual bundled scripts that are injected (not inlined).

How should I configure my build process? Thanks a mil!

Finger answered 28/9, 2017 at 18:50 Comment(2)
Hi @Finger were you able to solve this problem? We're running into a similar situation.Clements
@JoeM unfortunately not :/Finger

© 2022 - 2024 — McMap. All rights reserved.