Answer the question
In order to leave comments, you need to log in
How to force webpack to render styles as .css and not .js?
I have webpack settings like this:
const path = require('path')
const HTMLWebpackPlugin = require('html-webpack-plugin')
const { CleanWebpackPlugin } = require('clean-webpack-plugin')
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
module.exports = {
context: path.resolve(__dirname, 'src'),
mode: 'development',
module:{
rules: [
{
test: /\.css$/i,
use: [MiniCssExtractPlugin.loader, "css-loader"],
},
{
test: /\.html$/i,
loader: "html-loader",
},
// Правила для стилей
{ test: /\.txt$/, use: 'raw-loader' },
{
test: /\.scss$/,
use: [
"style-loader", // 3. Inject styles into DOM
"css-loader", // 2. Turns css into commonjs
"sass-loader", // 1. Turns sass into css
],
},
]
},
entry: {
app:[
path.resolve(__dirname, './src/index.html'),
path.resolve(__dirname, './src/assets/styles/style.scss'),
path.resolve(__dirname, './src/assets/styles/reset.scss')
]
},
output: {
path: path.resolve(__dirname, 'dist'),
filename: 'js/[name].js'
},
plugins: [
new HTMLWebpackPlugin({
template: "./index.html",
title: 'DIGITAL'
}),
new CleanWebpackPlugin(),
new MiniCssExtractPlugin()
]
}
Answer the question
In order to leave comments, you need to log in
"style-loader", // 3. Inject styles into DOM
should be here tooMiniCssExtractPlugin.loader
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question