Results 1 to 2 of 2

Thread: "npm run build" modifies index.html

  1. #1

    Join Date
    Nov 2010
    Location
    Canton, GA, USA
    Posts
    190
    Answers
    6

    Default Answered: "npm run build" modifies index.html

    I originally asked this at https://www.sencha.com/forum/showthr...ies-index-html but never got a response. Now that I have access to this forum, asking again.

    Using NPM and the Open Tooling setup, running "npm run build" modifies the original index.html file to insert a <base href="/"> tag at the top and <script src="main.js..."></script> at the bottom. If I run the build again, another copy if the script is added each time. These tags also end up in the production version which causes them to fail as that main.js isn't included in production.

    My hack to work around this is the adjust my Makefile to add a sed command after the build to revert those additions. A hack at best.

    I tried renaming index.html to index.html.tpl and adding "template: 'inced.html.tpl', filename: 'index.html'" to the HtmlWebpackPlugin config. This worked in dev but when I build production, the resulting index.html is now empty.

    Looking for someone who's webpack foo is greater than mine to straighten this out.

  2. The template I'm using (moderndesktopminimal I think) has been updated with the recent 7.1 release to add logic to remove the injected <script/> tag before building. It has changes in the webpack config to remove the tag and to disable the "hash" option so now the regenerated index.html matches what was there to start. This resolves my issue.

  3. #2

    Join Date
    Nov 2010
    Location
    Canton, GA, USA
    Posts
    190
    Answers
    6

    Default

    The template I'm using (moderndesktopminimal I think) has been updated with the recent 7.1 release to add logic to remove the injected <script/> tag before building. It has changes in the webpack config to remove the tag and to disable the "hash" option so now the regenerated index.html matches what was there to start. This resolves my issue.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •