webpack入门第六节:使用babel-loader转换ES6(下)

使用babel-loader转换ES6(下)

这一节讲了如何引用NODEJS里面的API path,这个目录的绝对路径

var htmlWebpackPlugin = require('html-webpack-plugin');
var path = require('path');

module.exports = {
    entry: './src/components/app.js',
    output: {
        path: __dirname + '/dist',
        filename: 'js/[name].bundle.js',
    },
    module:{
        loaders:[
            {
                test:/.\js$/,
                loader:'babel',
                //loader src目录下的所有文件 resolve意思为把它解析为绝对路径
                include:path.resolve(__dirname,'src'),
                //loader时不包括node_modules
                exclude:path.resolve(__dirname,'node_modules'),
                //制定loader的参数
                query:{
                    presests:['latest']
                }
            }
        ]
    },
    plugins: [
        new htmlWebpackPlugin({
            filename:'index.html',
            template:'index.html',//引用的H5模板
            inject:'body'
        })
    ]
}

猜你喜欢

转载自blog.csdn.net/weixin_42450794/article/details/81813659