Answer the question
In order to leave comments, you need to log in
What needs to be written in the webpack config so that it becomes possible to write all the styles not in one scss file, but in several?
I set up webpack, if you write all the styles in one scss file and connect it, then everything is OK, but if you split it into several separate files and import them into one and connect it, then there are problems with the assembly and the styles are not connected. Can you tell me what needs to be fixed in the webpack config file?
const path = require("path");
const HTMLWepackPlugin = require("html-webpack-plugin");
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const { CleanWebpackPlugin } = require("clean-webpack-plugin");
module.exports = {
mode: "development",
entry: "./src/index.js",
output: {
filename: "bundle.js",
path: path.resolve(__dirname, "dist"),
},
devServer: {
port: 3000,
hot: true,
open: true,
overlay: true,
contentBase: "./dist",
},
plugins: [
new HTMLWepackPlugin({
template: "./src/index.html",
}),
new MiniCssExtractPlugin({
filename: "[name].css",
chunkFilename: "[id].css",
}),
new CleanWebpackPlugin(),
],
module: {
rules: [
{
test: /\.js$/,
use: "babel-loader",
exclude: [/node_modules/],
},
{
test: /\.html/,
loader: "html-loader",
options: {
esModule: false,
},
},
{
test: /\.(png|jpg|gif|svg)$/,
use: [
{
loader: "file-loader",
options: {
name: "[name].[ext]",
esModule: false,
},
},
],
},
{
test: /\.(sass|scss)$/,
use: [
{
loader: MiniCssExtractPlugin.loader,
},
{
loader: "css-loader",
},
{
loader: "sass-loader",
},
],
},
],
},
};
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