admin管理员组文章数量:1415673
I have a working webpack 1 project that I want to migrate to webpack 2.
It is almost working, my main remaining problem is with html-webpack-plugin:
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?
I have a working webpack 1 project that I want to migrate to webpack 2.
It is almost working, my main remaining problem is with html-webpack-plugin:
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?
Share Improve this question asked Apr 3, 2017 at 18:13 laruisslaruiss 3,8161 gold badge20 silver badges29 bronze badges1 Answer
Reset to default 9Try setting output.publicPath
explicitly:
output : {
filename : 'static/js/bundle.js',
path : paths.appBuild,
publicPath : '/'
}
本文标签: javascripthtmlwebpackplugin and webpack 2 no starting slash 3939Stack Overflow
版权声明:本文标题:javascript - html-webpack-plugin and webpack 2: no starting slash '' - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745197978a2647232.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论