react webpack.config 配置文件

module. exports = {
     entry: "./app.js", //入口文件
     output:{
         path:__dirname, //输出的目录
         filename: 'bundle.js' //输出的文件名称
    },
     devtool: "source-map", //便于调试,相当于命令行中 webpack --devtool source-map
    module: { //依赖的模块
        rules: [ //模块、规则,如果在webpack旧版本中用的不是rules。用的是loaders
            {
                test: / \. js $ /,
                loader: 'babel-loader',
                query:{ //es6预设
                presets:[ "es2015", "react"],
                }
            },
            {
                test: / \. css $ /,
                exclude: /node_modules/,
                loader: 'style!css?module&localIdentName=[hash:base64:5]&-url'
            },
            {
                test: / \. scss $ /,
                exclude: /node_modules/,
                loader: 'style-loader!css-loader!sass-loader'
            },
            { //背景图片
                 test: / \. ( jpg | png | gif ) $ /,
                 loader: "url-loader?limit=1024"
            },
            { //字体文件
                 test: / \. ( eot | woff | svg | ttf | woff2 | gif | appcache )( \? |$ ) /,
                 loader: 'file-loader?name=[name].[ext]'
            }
    
        ]
    },
     devServer: {
        host: '0.0.0.0', //可以适用与手机浏览器
        port: 5000 //端口
    }
}

你可能感兴趣的:(react部分组件)