Answer the question
In order to leave comments, you need to log in
How to upload all pictures in webpack?
Hello, I have such a dilemma:
You need to load all the images from the img folder and connect them right there
and not manually, like here
My webpack.config.jsimport './img/image.png'
const path = require('path') // Модуль NodeJS для работы с путями
const HTMLPlugin = require('html-webpack-plugin')
const MiniCssExtractPlugin = require("mini-css-extract-plugin")
const OptimizeCssAssetsPlugin = require('optimize-css-assets-webpack-plugin')
const UglifyJsPlugin = require('uglifyjs-webpack-plugin')
module.exports = {
entry: ['./src/index.js'],
output: {
filename: 'bundle.js',
path: path.resolve(__dirname, 'dist')
},
optimization: {
minimizer: [
new OptimizeCssAssetsPlugin({}),
new UglifyJsPlugin({})
]
},
devServer: {
contentBase: __dirname + '/dist',
host: '192.168.1.77'
},
plugins: [
new HTMLPlugin({
filename: 'index.html',
template: './src/index.pug'
}),
new MiniCssExtractPlugin({
filename: 'style.css'
})
],
resolve: {
extensions: ['.js']
},
module: {
rules: [
{ test: /\.pug$/, loader: 'pug-loader', options: { pretty: true } },
{ test: /\.js$/, exclude: /node_modules/, loader: 'babel-loader' },
{ test: /\.css$/, use: [MiniCssExtractPlugin.loader, 'css-loader'] },
{ test: /\.(png|svg|jpg|gif)$/, use: ['file-lodaer']}
]
}
}
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