代码拉取完成,页面将自动刷新
const path = require('path');
const { edit, getPaths } = require('@rescripts/utilities');
// test a Webpack "test" rule against a string
const doTest = (test, matchStr) => {
if (Symbol.iterator in test) {
return Array.from(test).some(x => x.test(matchStr));
} else if (test instanceof RegExp) {
return test.test(matchStr);
}
throw new Error("Provided test was not an array or RegExp");
}
// determine if an object is a webpack rule that loads TypeScript
const isTsRule = obj => obj && obj.test && obj.loader && doTest(obj.test, "file.ts");
module.exports = [
// disable warnings for code generated by Flatbuffers compiler
["use-eslint-config", {
"extends": ["react-app"],
"overrides": [
{
"files": ["**/*_generated.ts"],
"rules": {
"no-redeclare": 0,
"@typescript-eslint/no-unused-vars": 0
}
}
]
}],
(config) => {
// don't load generated schema with babel-loader
config = edit(
(rule) => {
if (!rule.hasOwnProperty("exclude"))
rule.exclude = [];
rule.exclude.push(path.resolve(__dirname, "src/schema_generated.ts"));
return rule;
},
getPaths(isTsRule, config),
config,
);
// load generated schema with ts-loader
config = edit(
(module) => {
module.rules.unshift({
include: [path.resolve(__dirname, "src/schema_generated.ts")],
loader: require.resolve("ts-loader"),
options: {
configFile: "tsconfig.tsc.json"
}
});
return module;
},
getPaths(x => x.rules, config),
config
);
return config;
}
];
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。