码迷,mamicode.com
首页 > Web开发 > 详细

webpack+react配置UglifyJsPlugin出现的问题

时间:2017-07-14 23:13:21      阅读:516      评论:0      收藏:0      [点我收藏+]

标签:意思   ade   image   out   include   url   .json   put   webp   

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出现的问题

标签:意思   ade   image   out   include   url   .json   put   webp   

原文地址:http://www.cnblogs.com/zhengmiaohua/p/7172924.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!