老师,为啥我加了个outputPath:'/images' 图片就出不来了呢?
来源:3-2 使用 Loader 打包静态资源(图片篇)
 
			懵逼猫
2021-03-19
const path = require('path')
module.exports = {
    entry: './src/index.js',
    mode: 'development',
    module: {
        rules: [
            {
                test: /\.(jpg|png|gif)$/,
                use: {
                    loader: 'url-loader',
                    options: {
                        //placeholder 占位符
                        name: '[name]-[hash].[ext]',
                        outputPath: '/images',
                        limit:10240
                        // emitFile: false,
                    }
                }
            },
            {
                test: /\.css$/,
                use: [
                    'style-loader',
                    'css-loader'
                ]
            }
        ]
    },
    output: {
        filename: 'bundle.js',
        path: path.resolve(__dirname, 'dist')
    }
}
去掉images在dist目录下引入index.html就可以显示出来图片,但是加上outputPath:’/images’ ,打包里面有图片,但是在浏览器里面图片显示的 
图片的路径是/images/lh-3c720fd2197b2d74071d6395692d9c7e.jpg
显示就如上图所示,是个烂图片,但是在/images 前面加/dist
如:/dist/images/lh-3c720fd2197b2d74071d6395692d9c7e.jpg就能显示出来,是打包的时候少配置了什么吗?麻烦老师检查一下呢
写回答
	1回答
- 
				  Dell 2021-03-19 outputPath: '/dist/images', 032021-03-21
相似问题
