我使用mxstbr/react-boilerplate使用了很棒的DllPlugin,但由于应用程序由<body>
<div class="well window">
<div class="slider-frame-wrapper">
<ul class="slider-frame">
<li class="slider-panel"><h2><a title="iPhone" href="#/apple- c-19.html">iPhone</a></h2></li>
<li class="slider-panel"><h2>
<a title="Samsung" href="#/samsung-c-21.html">Samsung</a></h2>
</li>
<li class="slider-panel"><h2>
<a title="LG" href="#/lg-c-23.html">LG</a></h2>
</li>
<li class="slider-panel"><h2>
<a title="Huawei" href="#/huawei-c-31.html">Huawei</a></h2>
</li>
<li class="slider-panel"><h2>
<a title="Sony" href="#/sony-c-24.html">Sony</a></h2>
</li>
</ul>
</div>
</body>
下的nginx提供,因此在尝试获取{{}时失败了404来自根网址的{1}}文件(它会点击/admin
而不是reactBoilerplateDeps.dll.js
)。
在DllPlugin上是否有与Webpack的publicPath选项类似的概念,或者是否告诉在路径前缀下使用的DllPlugin?
答案 0 :(得分:0)
我添加了前缀where the dll scripts are appended to the body:
dllNames.forEach((dllName) => body.append(`<script data-dll='true' src='/${dllName}.dll.js'></script>`));
至
dllNames.forEach((dllName) => body.append(`<script data-dll='true' src='/${somePrefix}${dllName}.dll.js'></script>`));
此外,根据您如何代理请求,您应确保开发服务器正确处理文件名。因此,如果您还要将前缀传递给开发服务器,则应将其从请求路径here中删除。
答案 1 :(得分:0)
For webpack.dev.babel.js format, click here
I was struggling with the same but tried the following :
1) Go to you webpack.dev.babel.js
2) Go to the line where you've added this :
dllNames.forEach((dllName) => body.append(<script data-dll='true' src='/${dllName}.dll.js'></script>
));
3) Remove 'backslash'(/) as node_modules files once installed are publicly available. So, after removing, it will be :
dllNames.forEach((dllName) => body.append(<script data-dll='true' src='${dllName}.dll.js'></script>
));
4) run npm run build:dll
5) npm start
I hope, it helps.