var htmlWebpackPlugin=require('html-webpack-plugin');
var webpack=require('webpack');
var path=require('path');
module.exports={
context:__dirname,
entry:'./src/app.js',
output:{
path:path.resolve(__dirname,'./dist'),
filename:'js/[name].bundle.js'
},
module:{
rules:[
{
test:/\.js$/,
loader:'babel-loader',
exclude:path.resolve(__dirname,'/node_modules/'),//已经引用过的,已经打包过的文件
include:path.resolve(__dirname,'/src/'),
query:{
presets:['latest']
}
},
{
test:/\.css$/,
use:[
{
loader:'style-loader'
},
{
loader:'css-loader',
options:{
importLoaders:1
}
},
{
loader:'postcss-loader'
}
]
},
{
test:/\.less$/,
use:[
'style-loader',
'css-loader',
'postcss-loader',
'less-loader'
]
},
{
test:/\.scss$/,
use:[
'style-loader',
'css-loader',
'postcss-loader',
'sass-loader'
]
}
]
},
plugins:[
new htmlWebpackPlugin({
filename:'index.html',
template:'index.html',
inject:'body'
}),
new webpack.LoaderOptionsPlugin({
options:{
postcss:function(){
return [
require('autoprefixer')({
broswers:['last 5 versions']
})
]
}
}
})
]
};