let path = require('path');
let htmlWebpackPlugin = require('html-webpack-plugin');
let VueLoaderPlugin = require('vue-loader/lib/plugin');
module.exports = {
entry:'./src/main.js',
output:{
filename:'bundle.js',
path:path.resolve('./dist')
},
module:{
rules:[
//模块解析规则
//匹配所有的js,用babel-loader转义,排除node_modules
{test:/\.js$/,use:'babel-loader',exclude:/node_modules/},
{test:/\.css$/,use:['style-loader','css-loader']},
{test:/\.less$/,use:['style-loader','scc-loader','less-loader']},
//转换base64只在8192字节下转化。其他情况下输出图片
{test:/\.(jpg|gif|png)$/,use:'url-loader?limit=8192'},
//配置一些小图标单独写
// {test:/\.(eot|svg|woff|woff2|wtf)$/,use:'url-loader'},
{test:/\.vue$/,use:'vue-loader'}
]
},
plugins:[
new htmlWebpackPlugin({
template:'./src/index.html'
}),
new VueLoaderPlugin()
]
}
网友评论