Html-webpack-plugin: No starting slash '/' when using webpack 2

Created on 3 Apr 2017  路  3Comments  路  Source: jantimon/html-webpack-plugin

Hello, I need this plugin, but when I use it in webpack 2, the generated script tag is of the form:

<script type="text/javascript" src="static/js/bundle.js"></script>

instead of:

<script type="text/javascript" src="/static/js/bundle.js"></script>

Note: with the same plugin options, it works as expected in Webpack 1.

Here are the relevant parts of webpack conf:

  entry: [
    paths.appIndexJs,
    publicPath,
  ],
  output: {
    pathinfo: true,
    path: paths.appBuild,
    filename: 'static/js/bundle.js',
  },

  // (...)

  plugins: [
    new HtmlWebpackPlugin({
      inject: true,
      template: paths.appHtml,
    }),

What am I doing wrong?

Most helpful comment

I added output.publicPath = '/' and it was OK, I think it would be nice to have this in the examples and/or doc...

All 3 comments

I added output.publicPath = '/' and it was OK, I think it would be nice to have this in the examples and/or doc...

so why i have to set output.publicPath: '/' ?

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