Angular2 + webpack-hot-middleware + express / feathers

时间:2016-04-14 11:19:51

标签: javascript express angular webpack webpack-hot-middleware

我相信我的应用程序中有一些关于路径或类似内容的简单问题。

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的express服务器,我可以在localhost上加载索引页面,但是它会为webpack脚本抛出404,如下所示:

AngularWebpack

0 个答案:

没有答案