我相信我的应用程序中有一些简单的路径或类似问题。
App Structure:
root/public/build <-- publicPath in webpackConfig
root/public/index.html <-- Statically sitting there
root/client/ <-- client/angular2 source code
root/server/ <-- express/featherjs server
index.html 的内容
<html>
<head>
<title>Angular Webpack</title>
</head>
<body>
<app>Loading...</app>
<script src="/build/vendor.bundle.js"></script>
<script src="/build/bundle.js"></script>
</body>
</html>
webpackConfig:(仅限入口和输出部分)
entry: {
'main': [
'webpack/hot/dev-server',
'webpack-hot-middleware/client?path=/__webpack_hmr&timeout=20000',
path.join(__dirname, 'client', 'bootstrap.ts')
],
'vendor': [
path.join(__dirname, 'client', 'vendor.ts'),
'webpack-hot-middleware/client?path=/__webpack_hmr&timeout=20000'
]
},
output: {
path: path.join(__dirname, 'public/build'),
filename: 'bundle.js',
publicPath: '/build'
},
webpack 在 public/build 文件夹中构建。现在,在配置了 webpack-hot-middleware 的快速服务器运行时,我可以在 localhost 加载索引页面,但它会为 webpack 脚本抛出 404,如下所示: