vue2: p25 webpack把js和图片打包输出到专用目录
1 把图片输出到指定目录imgs中,配置webpack.config.js
module:{
rules:[
{test:/\.css$/,use:['style-loader','css-loader']},
{test:/\.less$/,use:['style-loader','css-loader','less-loader']},
//【1】&outputPath=xxx
{test:/\.jpg|png|gif$/,use:'url-loader?limit=10000&outputPath=imgs'},
{test:/\.js$/,use:'babel-loader',exclude:'/node_modules/'}
]
}
或写成
{test:/\.jpg|png|gif$/,use:{
loader:'url-loader',
options:{
limit:10000,
outputPath:'imgs'
}
}},
2 把js输出到指定 目录webpack.config.js
output:{
path:path.join(__dirname,'./dist/'),
filename:'js/main.js'
},