webpack-contrib/cache-loader

cache-loader causes imagemin-webpack-plugin to not generate the images

xxssww0258 opened this issue · 4 comments

module:{
	rules:[
		{
			test:/\.jsx?$/,
			include:[srcPath],
			use:[
				{
					loader:'cache-loader',
				},{
					loader:'babel-loader',
				}
			]
		},
		{
			test: /\.(css|scss)$/,
			include: [srcPath],
			use: ExtractTextPlugin.extract({
				fallback: 'style-loader',
				use: ['cache-loader','css-loader', 'sass-loader']
			})
		},
		{
			test:/\.(png|jpe?g|gif|svg)(\?.*)?$/,
			include:[srcPath],
			use:[
				{
					loader:'cache-loader'
				},{
					loader:'url-loader',
					options:{
						publicPath:'/',
						limit: 10000,
						name: utils.resourcePath('img/[name].[hash:7].[ext]')
					},
				}
			]
		},
		{
			test:/\.(mp4|webm|ogg|mp3|wav|flac|aac)(\?.*)?$/,
			include:[srcPath],
			use:[
				{	
					loader:'cache-loader'
				},{
					loader:'url-loader',
					options:{
						publicPath:'/',
						limit: 10000,
						name: utils.resourcePath('media/[name].[hash:7].[ext]')
					},
				}
			]
		},
		{
			test:/\.(woff2?|eot|ttf|otf)(\?.*)?$/,
			include:[srcPath],
			use:[
				{
					loader:'cache-loader'
				},{
					loader:'url-loader',
					options:{
						publicPath:'/',
						limit: 10000,
						name: utils.resourcePath('fonts/[name].[hash:7].[ext]')
					},
				}
			]
		}
	]
},
Hash: c593f2eeb3a74cc82923
Version: webpack 3.5.5
Time: 40972ms
                                Asset       Size  Chunks                    Chunk Names
  ./js/vendor.26bfd90b6f42c7d80bfa.js    1.18 MB       0  [emitted]  [big]  vendor
   ./js/index.6ae9e86f6a638e7fe8be.js     876 kB       1  [emitted]  [big]  index
./js/manifest.92cf23c7c278d9152237.js    1.45 kB       2  [emitted]         manifest
               css/index-c593f2ee.css     342 kB       1  [emitted]  [big]  index
                           index.html  510 bytes          [emitted]

No picture

@xxssww0258 can your provide minimum test repo? But seems problems in imagemin-webpack-plugin, not in cache-loader

testRepo

I found it wasn't imagemin-webpack-plugin's problem.
This should be my configuration error.

That's what I did

npm run build

Hash: ee66468368484d612a6c
Version: webpack 3.5.5
Time: 3299ms
                                Asset       Size  Chunks             Chunk Names
    resource/img/test_img.f83b5b7.png    67.5 kB  <== pictures       [emitted]
     ./js/app.975a87a17b4595766a02.js  272 bytes       0  [emitted]  app
./js/manifest.6b659a3ac207825e6291.js    1.43 kB       1  [emitted]  manifest
                             app.html  392 bytes          [emitted]

delete /src/dist/**
Once againnpm run build

Hash: ee66468368484d612a6c
Version: webpack 3.5.5
Time: 1123ms
                                Asset       Size  Chunks             Chunk Names
                                         ??? <== no pictures
     ./js/app.975a87a17b4595766a02.js  272 bytes       0  [emitted]  app
./js/manifest.6b659a3ac207825e6291.js    1.43 kB       1  [emitted]  manifest
                             app.html  392 bytes          [emitted]

Can't the add cache-loader to img?

@xxssww0258 thanks, in near future i will investigate this, thanks!

@xxssww0258 it seems, that cache-loader emits only changed files.

I try to change svg-icon in sources, and it was successfully generated after build.

This statement applies to other file types (e.g. html generated from pug).