Html-webpack-plugin: How to put / in front of the bundle file

Created on 13 Mar 2017  路  2Comments  路  Source: jantimon/html-webpack-plugin

Dear all

I'm using very simple html-webpack-plugin setup

module.exports = {
    ...
    plugins: [
        new HtmlPlugin({
            template: './template.html'
        })
    ]
}

The output HTML <script> is: <script type="text/javascript" src="ab56bd038d9a7da68390.bundle.js"></script>

Is it possible to have output HTML <script> to <script type="text/javascript" src="/ab56bd038d9a7da68390.bundle.js"></script> (/ in front of the bundle file) because without / I have a problem when using with react-router e.g. when the URL was http://localhost:8080/customers/101 the browser will look for /customers/ab56bd038d9a7da68390.bundle.js instead of /ab56bd038d9a7da68390.bundle.js

Please guide thanks

Most helpful comment

Try this

module.exports = {
    ...
    output: {
        publicPath: '/',
        ...
    },
    plugins: [
        new HtmlPlugin({
            template: './template.html'
        })
    ]
}

All 2 comments

Try this

module.exports = {
    ...
    output: {
        publicPath: '/',
        ...
    },
    plugins: [
        new HtmlPlugin({
            template: './template.html'
        })
    ]
}

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

ghaiklor picture ghaiklor  路  3Comments

var-bp picture var-bp  路  3Comments

amorphius picture amorphius  路  3Comments

lonelydatum picture lonelydatum  路  3Comments

meleyal picture meleyal  路  3Comments