ASP.net MVC + Webpack + React - 寻找错误的端口

时间:2016-05-13 01:11:36

标签: asp.net reactjs webpack

Webpack在与asp.net服务器一起使用时查找错误的端口。 我正在使用webpack dev服务器来提供我的应用程序。目前它正确加载,我可以访问bundle.js,但是一旦我更新了webpack的内容:

bundle.js:26 GET http://localhost:8080/static/b87f4fdf1db85f893152.hot-update.json 404 (Not Found)hotDownloadManifest @ bundle.js:26hotCheck @ bundle.js:245check @ only-dev-server.js:12(anonymous function) @ only-dev-server.js:70
only-dev-server.js:27 [HMR] Cannot find update. Need to do a full reload!
only-dev-server.js:28 [HMR] (Probably because of restarting the webpack-dev-server)

脚本文件包含在我的视图中:

<script type="text/javascript" src="http://localhost:3000/static/bundle.js" ></script>

server.js文件

var webpack = require('webpack');
var WebpackDevServer = require('webpack-dev-server');
var config = require('./webpack.config');
var port = 3000;
new WebpackDevServer(webpack(config), {
    publicPath: config.output.publicPath,
    hot: true,
  historyApiFallback: true,
    stats : {
        colors: true
    }
})
.listen(port, 'localhost', function (err) {
    if (err) {
        console.log(err);
    }
    console.log('Listening at localhost:%s', port);
});

和webpack文件

/* eslint-disable no-var */
var webpack = require('webpack');
var path = require('path');
var ExtractTextPlugin = require('extract-text-webpack-plugin');

module.exports = {
    entry: [
    'webpack-dev-server/client?http://0.0.0.0:3000',
    'webpack/hot/only-dev-server',
        './src/index.jsx'
    ],
    output: {
        path: __dirname,
        filename: 'bundle.js',
        publicPath: '/static/'
    },
    resolve: {
        extensions: ['', '.js', '.json', '.less', '.jsx']
    },
    devtool: 'eval',
    plugins: [
    new webpack.HotModuleReplacementPlugin(),
    new webpack.optimize.OccurenceOrderPlugin(),
    new webpack.optimize.DedupePlugin(),
    new ExtractTextPlugin('bundle.css', { allChunks: true }),
             new webpack.DefinePlugin({
                'process.env':{
                        'NODE_ENV': JSON.stringify('development')
                }
                })
    ],
    module: {
        loaders: [
            {
                    test: /\.(jsx|js)/,
                    loaders: ['react-hot', 'babel'],
                    resolve: ['.js', '.jsx'],
                    exclude: /node_modules/,
                    include: path.join(__dirname, 'src')
            },
            {
                    test: /(\.css|.less)$/,
                    loader: ExtractTextPlugin.extract('style-loader', 'css-loader!less-loader'),
                    resolve:['.less']
            },
            {
                    test: /\.(otf|eot|svg|ttf|woff)/,
                    loader: 'url-loader'
            }
        ]
    }
};

0 个答案:

没有答案