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!
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.
Most helpful comment
Just set the publicPath to './'