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'
    },

posted @ 2022-03-22 17:10  晨光曦微  阅读(359)  评论(0编辑  收藏  举报