Answer the question
In order to leave comments, you need to log in
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(),
]
};
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question