jharris4 / html-webpack-tags-plugin

lets you define html tags to inject with html-webpack-plugin
MIT License
255 stars 31 forks source link

path normalization on windows #44

Closed maiwenan closed 5 years ago

maiwenan commented 5 years ago

Hi, when using html-webpack-tags-plugin under windows, it generates the path link: <link href=\lib\__MOEBIUS__.css?c69a3b2f8dc75215ce4a rel=stylesheet>

image

here is my config:

{
  plugins: [
    new CopyWebpackPlugin([
      {
        from: 'dist-lib',
        to: 'lib/'
      }
    ]),
    new HtmlWebpackTagsPlugin({
      tags: [
        `lib/${PREFIX}.umd.min.js`,
        `lib/${PREFIX}.css`
      ],
      append: false,
      hash: true
    })
  ]
}

when I change the plugin code :

const DEFAULT_OPTIONS = {
  append: true,
  useHash: false,
  addHash: (assetPath, hash) => assetPath + '?' + hash,
  usePublicPath: true,
  addPublicPath: (assetPath, publicPath) => path.join(publicPath, assetPath),
  jsExtensions: ['.js'],
  cssExtensions: ['.css']
};

to

const DEFAULT_OPTIONS = {
  append: true,
  useHash: false,
  addHash: (assetPath, hash) => assetPath + '?' + hash,
  usePublicPath: true,
  addPublicPath: (assetPath, publicPath) => slash(path.join(publicPath, assetPath)),
  jsExtensions: ['.js'],
  cssExtensions: ['.css']
};

it workds.

Any help would be much appreciated! Please let me know if I can provide any more details.

jharris4 commented 5 years ago

Oh! I thought path.join was safe for windows! I'll go add that fix right now, thanks for reporting it!

jharris4 commented 5 years ago

I just released version 2.0.4 with a fix, please confirm whether it fixes the issue for you.

maiwenan commented 5 years ago

2.0.4 fixed the problem, thanks.