首页 > 代码库 > webpack+react配置UglifyJsPlugin出现的问题
webpack+react配置UglifyJsPlugin出现的问题
webpack.config.js中的配置
const path=require(‘path‘); const webpack=require(‘webpack‘); const HtmlWebpackPlugin=require(‘html-webpack-plugin‘); const CleanPlugin=require(‘clean-webpack-plugin‘); module.exports={ entry:‘./src/index.js‘, output:{ path:path.resolve(__dirname, ‘build‘), filename:‘[name]-[hash:5].js‘ }, module:{ rules:[{ test: /\.(jsx$|js)$/, exclude: /(node_modules|bower_components)/, include:/src/, use: { loader: ‘babel-loader‘, options: { presets: [‘env‘,‘react‘] } } }] /*loaders: [ { test: /\.css$/, loader: ‘style-loader!css-loader‘ }, { test: /\.scss$/, loader: ‘style!css!sass?sourceMap‘}, { test: /\.styl$/, loader: ‘style-loader!css-loader!stylus-loader‘}, { test: /\.(png|jpg)$/, loader: ‘url-loader?limit=8192‘}, { test: /\.js$/, loader: "babel-loader", query: {presets: [‘es2015‘,‘react‘]}} loader: ‘babel-loader?presets[]=es2015&presets[]=react‘ ]*/ }, resolve: { extensions:[‘.js‘,‘.json‘] }, plugins:[ new HtmlWebpackPlugin({ template:‘./src/index.html‘ }), new CleanPlugin(‘build‘), new webpack.optimize.UglifyJsPlugin({ compress:{ warnings:false } }) ] }
npm run webpack后有告警
意思好像是说生产环境和开发环境室友区别的
plugins再加上一项就没事了
new webpack.DefinePlugin({ ‘process.env‘: {NODE_ENV: ‘"production"‘} })
webpack+react配置UglifyJsPlugin出现的问题
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。