在creact-react-app当中使用craco插件,配置生产环境取消console解决办法(1)

“scripts”: {

  • “start”: “react-scripts start”,
  • “start”: “craco start”,
  • “build”: “react-scripts build”,
  • “build”: “craco build”,
  • “test”: “react-scripts test”,
  • “test”: “craco test”,

}

4.在生产模式下取消控制台的console配置

取消console,最常用方法是安装uglifyjs-webpack-plugin

const UglifyJsPlugin = require(‘uglifyjs-webpack-plugin’);

const UglifyJsPlugin = require(‘uglifyjs-webpack-plugin’);

module.exports = {

webpack: {

// 别名

alias: {

“@”: path.resolve(“src”),

},

plugins: [

new UglifyJsPlugin({

uglifyOptions: {

compress: {

warnings: false,

drop_debugger: true,

drop_console: true,

},

},

sourceMap: false,

parallel: true,

}),

],

}

你可能感兴趣的:(程序员,react.js,前端,前端框架)