ForkTsCheckerWarningWebpackPlugin

This commit is contained in:
Wang Kejun 2022-07-09 12:26:25 +08:00
parent e92ed95ee8
commit d98146b5ff
3 changed files with 30 additions and 4 deletions

View File

@ -11,7 +11,7 @@ const CopyWebpackPlugin = require('copy-webpack-plugin');
const TerserPlugin = require('terser-webpack-plugin');
const ForkTsCheckerWebpackPlugin =
process.env.TSC_COMPILE_ON_ERROR === 'true'
? require('react-dev-utils/ForkTsCheckerWarningWebpackPlugin')
? require('./../../plugins/ForkTsCheckerWarningWebpackPlugin')
: require('react-dev-utils/ForkTsCheckerWebpackPlugin');
const OakWeChatMpPlugin = require('../../plugins/WechatMpPlugin');

View File

@ -22,7 +22,7 @@ const getClientEnvironment = require('./env');
const ModuleNotFoundPlugin = require('react-dev-utils/ModuleNotFoundPlugin');
const ForkTsCheckerWebpackPlugin =
process.env.TSC_COMPILE_ON_ERROR === 'true'
? require('react-dev-utils/ForkTsCheckerWarningWebpackPlugin')
? require('./../../plugins/ForkTsCheckerWarningWebpackPlugin')
: require('react-dev-utils/ForkTsCheckerWebpackPlugin');
const ReactRefreshWebpackPlugin = require('@pmmmwh/react-refresh-webpack-plugin');
@ -681,9 +681,7 @@ module.exports = function (webpackEnv) {
javascriptEnabled: true,
modifyVars: oakConfigJson.theme,
};
},
}
),
},

View File

@ -0,0 +1,28 @@
/**
* Copyright (c) 2015-present, Facebook, Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
'use strict';
// References:
// - https://github.com/TypeStrong/fork-ts-checker-webpack-plugin#plugin-hooks
// - https://github.com/TypeStrong/fork-ts-checker-webpack-plugin/issues/232#issuecomment-645543747
const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');
module.exports = class ForkTsCheckerWarningWebpackPlugin {
constructor(options) {
this.options = options;
}
apply(compiler) {
new ForkTsCheckerWebpackPlugin(this.options).apply(compiler);
const hooks = ForkTsCheckerWebpackPlugin.getCompilerHooks(compiler);
hooks.issues.tap('ForkTsCheckerWarningWebpackPlugin', issues =>
issues.map(issue => ({ ...issue, severity: 'warning' }))
);
}
};