6 Star 27 Fork 8

dyb881/react to typescript

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
config-overrides.js 1.46 KB
一键复制 编辑 原始数据 按行查看 历史
dyb881 提交于 6年前 . 完善文档
const { override, addBabelPlugin, fixBabelImports, addLessLoader } = require('customize-cra');
const Merge = require('webpack-merge');
const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
const env = process.env.NODE_ENV;
const addImportAnt = libraryName =>
fixBabelImports(libraryName, {
libraryName,
libraryDirectory: 'es',
style: true,
});
module.exports = override(
addBabelPlugin('react-hot-loader/babel'),
addImportAnt('antd'),
addImportAnt('antd-mobile'),
addLessLoader({
javascriptEnabled: true,
modifyVars: {},
}),
// 自定义更改
config => {
// 添加ts代码审查
const forkTsCheckerWebpackPlugin = config.plugins[config.plugins.length - 1];
forkTsCheckerWebpackPlugin.tslint = './tslint.json';
forkTsCheckerWebpackPlugin.tslintVersion = require('tslint').Linter.VERSION;
if (env === 'production') {
config = Merge(config, {
devtool: false,
optimization: {
// 压缩代码
minimizer: [
new UglifyJsPlugin({
cache: true, // 启用文件缓存
parallel: true, // 使用多线程
uglifyOptions: {
compress: {
warnings: false, // 删除无用代码时不输出警告
drop_console: true, // 删除console语句
collapse_vars: true, // 内嵌定义了但是只有用到一次的变量
reduce_vars: true, // 提取出出现多次但是没有定义成变量去引用的静态值
},
},
}),
],
},
});
}
return config;
}
);
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
TypeScript
1
https://gitee.com/dyb881/react-ts.git
git@gitee.com:dyb881/react-ts.git
dyb881
react-ts
react to typescript
master

搜索帮助