Mengxin doesn't understand webpack include, asking for help.

problem description

I am new to webpack. When I used antd, to package the project, I found that I needed loader, for less, so I added less-loader, to the webpack configuration as follows

            {
                test: /\.less$/,
                use: [
                    "style-loader",
                    "css-loader",
                    {
                        loader: "less-loader",
                        options: {
                            javascriptEnabled: true
                        }
                    }
                ]
            }

later I thought that I only needed to parse the less file under antd, so I added the include entry as follows

            {
                test: /\.less$/,
                include: path.resolve(__dirname, "/node_modules/antd"),
                use: [
                    "style-loader",
                    "css-loader",
                    {
                        loader: "less-loader",
                        options: {
                            javascriptEnabled: true
                        }
                    }
                ]
            }

the result is wrong, as follows

clipboard.png
as a newcomer, I look confused. Isn"t that how include uses it?

Mar.17,2022

path.resolve (_ _ dirname, 'node_modules/antd')

Menu