如何解决忽略node_modules上的React警告
由于某种原因,我的构建仍在捕获和处理位于node_modules中的代码上的React警告。我想禁用该功能,但不确定如何仍在读取该代码。
我不在自己的代码中的任何地方使用componentWillMount
。它以某种方式在node_modules中获取。
webpack.config.js
const path = require('path');
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
const TerserJSPlugin = require('terser-webpack-plugin');
const HtmlWebPackPlugin = require('html-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin');
const CopyPlugin = require('copy-webpack-plugin');
const isProduction = process.env.NODE_ENV === 'production';
const html = () =>
new HtmlWebPackPlugin({
template: path.resolve(__dirname,'src/client','index.html'),filename: 'index.html',hash: true,});
const copyAllOtherDistFiles = () =>
new CopyPlugin({
patterns: [
{ from: 'src/client/assets',to: 'lib/assets' },{ from: 'package.json',to: './' },{ from: 'ext/ink-3.1.10/js/ink-all.min.js',to: 'lib/js' },{ from: 'ext/ink-3.1.10/js/autoload.min.js',{ from: 'ext/ink-3.1.10/css/ink-flex.min.css',to: 'lib/css' },{ from: 'ext/js/jquery-2.2.3.min.js',{ from: 'ext/ink-3.1.10/fonts',to: 'lib/css/fonts' },{ from: 'feed.xml',],});
module.exports = {
entry: './src/client/index.tsx',output: {
filename: 'scripts/app.[hash].bundle.js',publicPath: '/',path: path.resolve(__dirname,'dist'),},resolve: {
extensions: ['.ts','.tsx','.js'],devtool: 'source-map',devServer: {
open: true,writeToDisk: false,compress: true,historyApiFallback: {
index: '/',stats: 'errors-only',proxy: {
'/api': {
target: 'http://localhost:3000',secure: false,changeOrigin: true,logLevel: 'debug',optimization: {
splitChunks: {
cacheGroups: {
styles: {
name: 'styles',test: /\.css$/,chunks: 'all',enforce: true,module: {
rules: [
{
test: /\.(js)$/,exclude: /node_modules/,use: {
loader: 'babel-loader',{
test: /\.(tsx|ts)?$/,use: 'ts-loader',{
test: /\.html$/,use: [
{
loader: 'html-loader',{
test: /\.less$/,use: [MiniCssExtractPlugin.loader,'css-loader','less-loader'],{
test: /\.css$/,use: [
{
loader: MiniCssExtractPlugin.loader,options: {
publicPath: '../../',outputPath: 'lib/css',{
test: /\.(woff(2)?|ttf|eot|otf|svg)?$/,use: [
{
loader: 'file-loader',options: {
name: '[name].[ext]',publicPath: '/lib/css/fonts',// <--resolve the path in css files
outputPath: 'lib/css/fonts',// <-- path to place font files
},{
test: /\.(png|svg|jpg|gif)$/,use: ['url-loader'],plugins: isProduction
? [
new CleanWebpackPlugin(),copyAllOtherDistFiles(),new MiniCssExtractPlugin({
filename: 'lib/css/[name].[hash].css',}),html(),]
: [
copyAllOtherDistFiles(),};
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。