{"action":"opened","issue":{"url":"https://api.github.com/repos/jantimon/html-webpack-plugin/issues/822","repository_url":"https://api.github.com/repos/jantimon/html-webpack-plugin","labels_url":"https://api.github.com/repos/jantimon/html-webpack-plugin/issues/822/labels{/name}","comments_url":"https://api.github.com/repos/jantimon/html-webpack-plugin/issues/822/comments","events_url":"https://api.github.com/repos/jantimon/html-webpack-plugin/issues/822/events","html_url":"https://github.com/jantimon/html-webpack-plugin/issues/822","id":281186422,"number":822,"title":"Incorrect asset path when using publicPath on Windows","user":{"login":"kytrol","id":11355759,"avatar_url":"https://avatars3.githubusercontent.com/u/11355759?v=4","gravatar_id":"","url":"https://api.github.com/users/kytrol","html_url":"https://github.com/kytrol","followers_url":"https://api.github.com/users/kytrol/followers","following_url":"https://api.github.com/users/kytrol/following{/other_user}","gists_url":"https://api.github.com/users/kytrol/gists{/gist_id}","starred_url":"https://api.github.com/users/kytrol/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kytrol/subscriptions","organizations_url":"https://api.github.com/users/kytrol/orgs","repos_url":"https://api.github.com/users/kytrol/repos","events_url":"https://api.github.com/users/kytrol/events{/privacy}","received_events_url":"https://api.github.com/users/kytrol/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2017-12-11T22:15:50Z","updated_at":"2017-12-11T22:15:50Z","closed_at":null,"author_association":"NONE","body":"## Description\r\n`html-webpack-plugin` incorrectly constructs the asset path on Windows when a `publicPath` is specified.  I'd expect the `src` of the `<script>` to be `build\\js\\bundle.js` instead of `build\\/js\\bundle.js`. \r\n\r\nI found that this is caused by [this conditional](https://github.com/jantimon/html-webpack-plugin/blob/f6633391a281378a3fcd973165a4b0b72b8850c1/index.js#L401).\r\n\r\nWhen it is changed to:\r\n\r\n```js\r\nvar separator = path.join('/');\r\nif (publicPath.length && publicPath.substr(-1, 1) !== separator) {\r\n  publicPath += separator;\r\n}\r\n```\r\nThe asset path is correctly constructed. Though I don't know if this is the correct, robust solution. Should I even use the `path` module when setting paths in `webpack.config.js`?\r\n\r\nBelow is the minimum config to reproduce.\r\n\r\n### Config\r\n```js\r\nconst webpack = require('webpack');\r\nconst path = require('path');\r\nconst HtmlWebpackPlugin = require('html-webpack-plugin');\r\n\r\nmodule.exports = {\r\n  entry: path.join(__dirname, 'script.js'),\r\n  output: {\r\n    filename: path.join('js', 'bundle.js'),\r\n    path: path.join(__dirname, 'build'),\r\n    publicPath: path.join('build', '/')\r\n  },\r\n  plugins: [\r\n    new HtmlWebpackPlugin({\r\n      template: path.join(__dirname, 'index.html'),\r\n      filename: 'index.html',\r\n      minify: false,\r\n      inject: true\r\n    }),\r\n  ]\r\n};\r\n```\r\n\r\nTemplate file:\r\n\r\n```html\r\n<!DOCTYPE html>\r\n<html>\r\n  <head>\r\n    <meta charset=\"UTF-8\">\r\n    <title>Path Test</title>\r\n    <meta http-equiv=\"X-UA-Compatible\", content=\"IE=edge\">\r\n    <meta name=\"viewport\" content=\"width=device-width,initial-scale=1.0\">\r\n  </head>\r\n  <body>\r\n    <h1>Path Test</h1>      \r\n  </body>\r\n</html>\r\n```\r\n\r\nTemplate file after injection:\r\n\r\n```html\r\n<!DOCTYPE html>\r\n<html>\r\n  <head>\r\n    <meta charset=\"UTF-8\">\r\n    <title>Path Test</title>\r\n    <meta http-equiv=\"X-UA-Compatible\", content=\"IE=edge\">\r\n    <meta name=\"viewport\" content=\"width=device-width,initial-scale=1.0\">\r\n  </head>\r\n  <body>\r\n    <h1>Path Test</h1>\r\n  <script type=\"text/javascript\" src=\"build\\/js\\bundle.js\"></script></body>\r\n</html>\r\n```\r\n## Environment\r\nNode.js v8.9.1\r\nwin32 6.1.7601\r\nnpm v5.5.1\r\nwebpack@3.10.0\r\nhtml-webpack-plugin@2.30.1\r\n\r\n\r\n"}}
{"actor":{"display_login":"kytrol"}}