Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/webpack/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Webpack 网页包3不排除节点_模块_Webpack_Webpack 3 - Fatal编程技术网

Webpack 网页包3不排除节点_模块

Webpack 网页包3不排除节点_模块,webpack,webpack-3,Webpack,Webpack 3,这里我的webpack.config.js有什么问题,因为它无法排除节点_模块。我在以前版本的webpack中发现了类似的帖子,但由于语法不同,修复程序无法正常工作 module.exports = { context: __dirname, entry: './src/index.js', output: { path: __dirname + '/public/assets/', publ

这里我的webpack.config.js有什么问题,因为它无法排除节点_模块。我在以前版本的webpack中发现了类似的帖子,但由于语法不同,修复程序无法正常工作

    module.exports = {
        context: __dirname,
        entry: './src/index.js',
        output: {
            path: __dirname + '/public/assets/',
            publicPath: '/assets/js/',
            filename: 'bundle.js'
        },

        module: {
            rules: [
                {
                    test: /\.css$/,
                    include: /src/,
                    exclude: /node_modules/,
                    use: [
                        {loader: 'style-loader'},
                        {loader: 'css-loader'}
                    ]
                },
                {
                    test: /\.ejs$/,
                    include: /src/,
                    exclude: /node_modules/,
                    use: [
                        {loader: 'ejs-simple-loader'}
                    ]
                },
                {
                    test: /\.js$/,
                    include: /src/,
                    exclude: /node_modules/,
                    use: [
                        {loader: 'jshint-loader'}
                    ]
                },
                {
                    test: /\.jsx$/,
                    include: /src/,
                    exclude: /node_modules/,
                    use: [
                        {loader: 'babel-loader'}
                    ]
                }
            ]
        }
    }

您使用的规则需要
pre

您的代码应为:

module.exports = {
    entry: "./foo.js",
    output: {
        filename: "./bar.js"
    },

    module: {
        rules: [
            {
                test: /\.js$/,
                enforce: 'pre', // updated value
                exclude: /node_modules/,
                use: [
                    { loader: 'jshint-loader' }
                ]
            }
        ]
    }
};

来源:

谢谢,@robinCTS。我不明白为什么这被否决了。我复制了OPs问题,提供了解决方案,并添加了源代码。