webpack-dev-server错误:因为319不被接受而中止

时间:2016-10-19 09:34:43

标签: webpack-dev-server

enter image description here

当我运行webpack-dev-server时,它可以正常运行!我可以看到我的应用程序运行成功,但是当我更改代码时它无法自动重新加载!服务器也会崩溃!你可以请参阅我上传的错误信息img!

这是我的配置!!

var path = require('path');
var webpack = require('webpack');
var CopyWebpackPlugin = require('copy-webpack-plugin');
var HtmlWebpackPlugin = require('html-webpack-plugin');
var APP_PATH = path.resolve(__dirname, 'dist');
var SRC_PATH = path.resolve(__dirname, 'src');

var HOST = '127.0.0.1';
var PORT = '8080';

var config = {
    cache: true,
    target: 'web',

    devtool: 'source-map',
    entry: {
        app: [
            `webpack-dev-server/client?http://${HOST}:${PORT}`,         
            'webpack/hot/dev-server',
            './src/app.jsx',
        ]
    },
    output: {
        path: APP_PATH,
        filename: '[name].js',
        chunkFilename: '[chunkhash].js',
        sourceMapFilename: '[name].map'
    },
    module: {
        loaders: [
            {
                loader: 'babel-loader',
                include: [
                    SRC_PATH,
                ],
                exclude:[
                    path.resolve(__dirname,'node_modules'),
                ],

                // Only run `.js` and `.jsx` files through Babel
                test: /\.js|\.jsx?$/,

                // Options to configure babel with
                query: {
                    presets: ['es2015', 'react'],
                }
            },
            { test: /\.css$/, loader: 'style-loader!css-loader' },
            { test: /\.sass$/, loader: 'style-loader!css-loader!sass-loader'}
        ]
    },
    devServer: {
        contentBase: './dist',
        // do not print bundle build stats
        noInfo: true,
        // enable HMR
        hot: true,
        // embed the webpack-dev-server runtime into the bundle
        inline: true,
        // serve index.html in place of 404 responses to allow HTML5 history
        historyApiFallback: true,
        port: PORT,
        host: HOST
    },
    plugins: [
        new webpack.NoErrorsPlugin(),
        new webpack.˙˙(),
        new webpack.optimize.DedupePlugin(),
        new HtmlWebpackPlugin({
            template: './src/index.html'
        }),
        //new webpack.optimize.UglifyJsPlugin({comments: false}),
        new CopyWebpackPlugin([
            { from: path.resolve(SRC_PATH, 'main.js'), to: 'main.js' },
            { from: path.resolve(SRC_PATH, 'index.html'), to: 'index.html' },
            { from: path.resolve(SRC_PATH, 'package.json'), to: 'package.json' }
        ])
    ]
};

module.exports = config;

0 个答案:

没有答案