customize-cra 打包时 去除 map 文件
config-overrides.js
const { override, fixBabelImports, addLessLoader, addWebpackAlias } = require('customize-cra'); const path = require('path'); function resolve(dir) { return path.join(__dirname, '.', dir); } module.exports = override( // 配置路径别名 addWebpackAlias({ components: path.resolve(__dirname, 'src/components'), apps: path.resolve(__dirname, 'src/apps'), utils: path.resolve(__dirname, 'src/utils'), Images: path.resolve(__dirname, 'src/assets/images') }), fixBabelImports('import', { libraryName: 'ant-mobile', libraryDirectory: 'es', style: true }), addLessLoader({ javascriptEnabled: true, modifyVars: { '@primary-color': '#1DA57A' } }), (config)=>{ //暴露webpack的配置 // 去掉打包生产map 文件 // config.devtool = config.mode === 'development' ? 'cheap-module-source-map' : false; if(process.env.NODE_ENV==="production") config.devtool=false; return config } );
.