Html-webpack-plugin: Absolute path for `filename` option?

Created on 23 Mar 2016  路  4Comments  路  Source: jantimon/html-webpack-plugin

I am trying to generate the HTML file at a different location from other webpack built assets. However if I specify an absolute path for the filename option, the generated HTML file is still nested under webpack's output path. I assume this is due to how webpack interprets assets, but is there anyway to get around it?

Most helpful comment

That's not quite what I want - I want to generate the HTML to a location unrelated to the webpack output path. Also, specifying a nested path in output.filename is a less-than-optimal solution, because then I also have to do so for all other assets such as files processed by file-loader and CSS extracted with extract-text-webpack-plugin. If I want to change the nested folder, I now have to remember to edit all these paths.

It also feels "not working as expected" when you specify an absolute path and instead see it nested under another directory. In fact the fix is pretty simple, as implemented in this PR: https://github.com/ampedandwired/html-webpack-plugin/pull/266

All 4 comments

duplicate of #234 - I believe #250 has a good solution

http://stackoverflow.com/questions/36122972/preserving-folder-structure-in-output-directory-with-webpack

hope that helps

That's not quite what I want - I want to generate the HTML to a location unrelated to the webpack output path. Also, specifying a nested path in output.filename is a less-than-optimal solution, because then I also have to do so for all other assets such as files processed by file-loader and CSS extracted with extract-text-webpack-plugin. If I want to change the nested folder, I now have to remember to edit all these paths.

It also feels "not working as expected" when you specify an absolute path and instead see it nested under another directory. In fact the fix is pretty simple, as implemented in this PR: https://github.com/ampedandwired/html-webpack-plugin/pull/266

i think i found the solution , i need absolute path too, because i have to deploy in netlify and combine via _redirects file.

my solution :
in webpack config. set output.publicPath to /

...
output: {
    filename: "app/[name]-[hash].js",
    path: "dist",
    publicPath: "/"
  },
...

ref : https://stackoverflow.com/questions/36122972/preserving-folder-structure-in-output-directory-with-webpack

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

lonelyclick picture lonelyclick  路  3Comments

GerkinDev picture GerkinDev  路  3Comments

amorphius picture amorphius  路  3Comments

var-bp picture var-bp  路  3Comments

lcxfs1991 picture lcxfs1991  路  4Comments