Html-webpack-plugin: Change path of assets

Created on 4 Oct 2016  路  3Comments  路  Source: jantimon/html-webpack-plugin

I'm using webpack-dev-middleware to serve my files in memory while I develop鈥攚ith the publicPath property set to static. When I compile a build, I send the minified CSS and JS to a public folder for production.

_Here is an excerpt from config in the root of my project folder:_

// ...
output: {
    path: path.join(__dirname, 'public'),
    filename: 'js/[name].min.js',
    publicPath: '/static'
},
plugins: [
    new ExtractTextPlugin('css/[name].min.css', {allChunks: true}),
    new HtmlWebpackPlugin({minify: {collapseWhitespace: true}})
]
// ...

_This gives me the following:_

    public
        css
            bundle.min.css
        js
            bundle.min.js
        index.html

_These are the asset paths in the outputted HTML:_

<link href="/static/css/bundle.min.css" rel="stylesheet">
<script type="text/javascript" src="/static/js/bundle.min.js">

_I want it to be:_

<link href="./css/bundle.min.css" rel="stylesheet">
<script type="text/javascript" src="./js/bundle.min.js">

This looks like a _very_ powerful Webpack plugin; thank you for making it and look forward to hearing back!

Most helpful comment

Just set the publicPath to './'

All 3 comments

Just set the publicPath to './'

Example:

public/js/bundle.?.js
public/index.html

var buildPath = path.resolve(__dirname, 'public'); output: { path: buildPath, //Path where the bundle should be exported filename: 'js/bundle.[hash].js', //Filename publicPath: '/' //Where the js gets loaded from },

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

lonelydatum picture lonelydatum  路  3Comments

mmjamal picture mmjamal  路  3Comments

yyx990803 picture yyx990803  路  4Comments

laruiss picture laruiss  路  3Comments