webpack ^4.0.1 版本的webpack.config.js配置

var path = require("path");
module.exports = {
    entry:'./app/index.js',
    output:{
        filename:'index.js',
        path:path.resolve(__dirname,'dist'),
        publicPath:'temp/'                       //公共路径,从内存中读取
    },
    devServer:{
        contentBase:'./',
        host:'localhost',
        compress:true,
        port:1818
    },
    module:{
        rules:[ 
            {
                test:/\.js$/,
                exclude:/node_modules/,
                loader:'babel-loader',
                options:{
                    presets:["es2015","react"]
                }
            }
        ]
    }
}

以上是webpack ^4.0.1 版本的webpack.config.js文件的配置

参考官方文档  https://webpack.js.org/configuration/#options

我的目录及文件

webpack ^4.0.1 版本的webpack.config.js配置_第1张图片

webpack ^4.0.1 版本的webpack.config.js配置_第2张图片

webpack ^4.0.1 版本的webpack.config.js配置_第3张图片

你可能感兴趣的:(webpack,React)