Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

After webpack bundle can't read css background image #59

Open
merri23 opened this issue Aug 31, 2021 · 0 comments
Open

After webpack bundle can't read css background image #59

merri23 opened this issue Aug 31, 2021 · 0 comments

Comments

@merri23
Copy link

merri23 commented Aug 31, 2021

I have a problem. I converted all static images to .webp format. But in css files I have { background-image: url('./path/to/image.svg')} after bundle webpack can't read this one. I think webpack can't bundle this file, because in another css file I have ::before { background-image: url('./path/to/image.png')}... All css files where I have background-image can't bundle with webpack. In folder dist I didn't find it... Can you help me?

My webpack.config.js
const path = require('path')
const HTMLWebpackPlugin = require('html-webpack-plugin')
const {CleanWebpackPlugin} = require('clean-webpack-plugin')
const MiniCssExtractPlugin = require('mini-css-extract-plugin')

plugins: [
new HTMLWebpackPlugin({
template: './index.html',
minify: {
collapseWhitespace: isProd
}
}),
new CleanWebpackPlugin(),
new MiniCssExtractPlugin({
filename: 'css/[name].css'
}),
],
module: {
rules: [
{
test: /locales/,
loader: '@alienfast/i18next-loader',
},
{
test: /.css$/,
use: [MiniCssExtractPlugin.loader, 'css-loader']
},
{
test: /.s[ac]ss$/i,
use: [MiniCssExtractPlugin.loader, "css-loader", "sass-loader"]
},
{
test: /.(png|jpg|gif|webp)$/,
use: [
{
loader: 'url-loader',
options: {
name: 'images/[name].[ext]',
},
},
],
},
{
test: /.svg$/,
use: ['@svgr/webpack', 'url-loader'],
},
{
test: /.js$/,
exclude: /node_modules/,
loader: 'babel-loader'
},
{
test: /.jsx$/,
exclude: /node_modules/,
loader: 'babel-loader'
}
]
}

@merri23 merri23 closed this as completed Aug 31, 2021
@merri23 merri23 reopened this Aug 31, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant