升级到最新版本时,webpack Dev Server无效选项

时间:2019-09-02 11:02:06

标签: node.js reactjs webpack-dev-server webpack-4

我将项目升级到了最新的库

"@babel/core": "^7.5.5",  
"@babel/plugin-proposal-object-rest-spread": "^7.5.5",  
"@babel/preset-env": "^7.5.5",  
"@babel/preset-react": "^7.0.0",  
"webpack": "^4.39.3",  
"webpack-dev-server": "^3.8.0" 

但是我无法在开发人员模式下运行并获取此日志。

愚蠢的生命周期'webpack-dev-server --config webpack / webpack.dev.config.js --progress --colors --inline --hot']
错误代码ELIFECYCLE
错误errno 1

请帮助我检查以下配置。

module.exports = {
    context: rootDir,
    resolve: {
        extensions: ['*', '.js', '.jsx'],
        alias: {}
    },
    module: {
        rules: [{
                test: /\.(js|jsx)$/,
                use: [{
                    loader: "babel-loader",
                    options: {
                        babelrc: false,
                        presets: ['@babel/preset-env', '@babel/preset-react'],
                        plugins: [
                            (argv.inline && argv.hot ? [
                                'react-hot-loader/babel',
                                '@babel/plugin-proposal-object-rest-spread'
                            ] : ['@babel/plugin-proposal-object-rest-spread'])
                        ]
                    }
                }],
                exclude: /(node_modules|bower_components)/
            },
            {
                test: /\.less$/,
                exclude: [/node_modules/],
                use: [
                    // style-loader
                    {
                        loader: 'style-loader'
                    },
                    // css-loader
                    {
                        loader: 'css-loader',
                        options: {
                            modules: true
                        }
                    },
                    // less-loader
                    {
                        loader: 'less-loader'
                    },
                    //autoprefixer-loader
                    {
                        loader: 'autoprefixer-loader'
                    },
                ]
            },
            {
                test: /\.css/,
                exclude: [/node_modules/],
                use: [
                    // style-loader
                    {
                        loader: 'style-loader'
                    },
                    // css-loader
                    {
                        loader: 'css-loader',
                        options: {
                            modules: true
                        }
                    }
                ]
            },
            {
                test: /\.(png|jpg|gif)$/i,
                exclude: [/node_modules/],
                use: [{
                    loader: 'url-loader',
                    options: {
                        limit: 10000,
                    },
                }]
            }
        ],
        noParse: ['...']
    },
    optimization: {
        namedChunks: true,
        splitChunks: {
            chunks: 'all',
            minSize: 30000,
            maxSize: 0,
            minChunks: 1,
            maxAsyncRequests: 5,
            maxInitialRequests: 3,
            automaticNameDelimiter: '~',
            automaticNameMaxLength: 30,
            name: true,
            cacheGroups: [Object]
        }
    },
    plugins: [
        new webpack.HotModuleReplacementPlugin(),
        new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/),
    ]
    entry: {
        bundle: './src/app/main.jsx',
        vendor: ['react',
            'react-dom',
            'react-bootstrap',
            'react-router',
            'jquery',
            'jquery-ui',
            'moment',
            'moment-timezone',
            'easy-pie',
            'sparkline'
        ]
    },
    output: {
        path: path.resolve(__dirname, '../web/build'),
        publicPath: 'build/',
        filename: '[name].js ',
        chunkFilename: 'chunk.[id].js ',
        pathinfo: true
    },
    devServer: {
        contentBase: path.join(__dirname, 'web'),
        compress: true,
        devtool: 'eval',
        port: 14608,
        hot: false,
        inline: false
    },
    devtool: 'eval'
}

0 个答案:

没有答案