A
A
alaskafx2022-01-29 14:17:36
webpack
alaskafx, 2022-01-29 14:17:36

How to make webpack work with image from html and styles?

There is a configuration:

const path = require('path');
const miniCss = require('mini-css-extract-plugin');
const { CleanWebpackPlugin } = require('clean-webpack-plugin')
const HTMLWebpackPlugin = require('html-webpack-plugin')

module.exports = {
    mode: 'development',
    entry: {
        app: [
            path.resolve(__dirname, './src/bundleStyles.js'),
            path.resolve(__dirname, './src/main.js'),
        ]
    },
    output: {
        filename: 'bundle.js',
        path: path.resolve(__dirname, 'dist')
    },
    module: {
        rules: [
            {
                test: /\.(png|jpg)$/,
                use: [
                    {
                        loader: 'file-loader',
                        options: {
                            name: '[name].[ext]',
                            outputPath: 'img/',
                            publicPath: 'img/'
                        }
                    }
                ]
              },
            {
            test:/\.(s*)css$/,
            use: [
                miniCss.loader,
                'css-loader',
                'sass-loader',
            ]
        },
    ]
    },
    plugins: [
        new miniCss({
            filename: 'style.css',
        }),
        new HTMLWebpackPlugin({
             template: "./src/index.html",
             title: 'DIGITAL'
         }),
        new CleanWebpackPlugin(),
    ]
};


But I don't know: how to make webpack work with images:
How to do it?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question