My images from .scss file are shown in "dist/images", but they do not load on localhost. And images from html file ( kind) are not read at all, it seems to be loaded in "dist", but not "dist/images" and it is not visible on the page.
Can anyone see what is incorrect in my config?
Here is the config:
const path = require("path");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const { CleanWebpackPlugin } = require("clean-webpack-plugin");
const isProduction = process.env.NODE_ENV == "production";
const config = {
entry: "./src/index.js",
output: {
path: path.resolve(__dirname, "dist"),
filename: "bundle.js",
},
devtool: "source-map",
devServer: {
open: true,
host: "localhost",
hot: true,
},
plugins: [new MiniCssExtractPlugin(),
new CleanWebpackPlugin(),
new HtmlWebpackPlugin({
template: "index.html",
}),
],
module: {
rules: [
{
test: /\.(js|jsx)$/i,
loader: "babel-loader",
exclude: /node_modules/,
},
{
test: /\.(sass|less|css|scss)$/,
use: [
"css-loader", "sass-loader"],
},
{
test: /\.(jpe?g|png|svg)$/,
use: [{
loader: 'file-loader',
options: {
name: '[hash].[ext]',
outputPath: 'images'
},
}]
},
],
},
};
module.exports = () => {
if (isProduction) {
config.mode = "production";
config.plugins.push(new MiniCssExtractPlugin());
} else {
config.mode = "development";
}
return config;
};