here is my webpack config which shows i've added rules for less files, also as you can see in package.json, I have installed all less less-loader css-loader and whatever is needed for adding styles. but I constantly get these errors when building project what's wrong with my codes? thanks a lot in advance
webpack.config.js
const path = require('path')
const fs = require('fs')
const CopyWebpackPlugin = require('copy-webpack-plugin')
const Dotenv = require('dotenv-webpack')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const lessToJs = require('less-vars-to-js')
const themeVariables = lessToJs(fs.readFileSync(path.join(__dirname, './ant-theme-vars.less'), 'utf8'))
// lessToJs does not support @icon-url: "some-string", so we are manually adding it to the produced themeVariables js object here
themeVariables["@icon-url"] = "'http://localhost:8080/fonts/iconfont'";
const ebMode = process.env.eb_mode
const mode = process.env.NODE_ENV || 'development'
const version = new Date().getTime().toString()
const createConfig = (label, entry, target) => ({
entry,
output: {
filename: `app.js?v=${version}`,
path: path.resolve(__dirname, `dist/${label}`),
},
plugins: [
new Dotenv(),
// new CopyWebpackPlugin({
// patterns: [
// { from: './assets', to: './' }
// ],
// }),
new HtmlWebpackPlugin({
title: `${label} admin panel`,
template: path.resolve(__dirname, `public/${label}/index.html`),
filename: path.resolve(__dirname, `dist/${label}/index.html`),
}),
],
module: {
rules: [
{
test: /\.jsx?$/,
resolve: { extensions: ['.js', '.json', '.jsx', '.css', '.less'] },
exclude: /node_modules/,
loader: 'babel-loader',
},
{
test: /\.less$/,
use: [
{loader: 'style-loader'},
{loader: 'css-loader'},
{loader: 'less-loader',
options: {
lessOptions: {
strictMath: true,
},
}
}
]
},
{
use: ['style-loader', 'css-loader'],
test: /\.css$/
}
],
},
})
module.exports = createConfig
package.json
{
"name": "ant-template",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"build": "webpack --config ./main.webpack.config.js --mode production",
"watch": "webpack --config ./main.webpack.config.js --mode=development --watch",
"live": "serve -s -l 80 dist/main"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"antd": "^4.12.3",
"axios": "^0.21.1",
"dotenv": "^8.2.0",
"js-cookie": "^2.2.1",
"jss": "^10.5.1",
"jss-preset-default": "^10.5.1",
"lodash": "^4.17.21",
"react": "^17.0.1",
"react-dom": "^17.0.1",
"react-jss": "^10.5.1",
"react-router-dom": "^5.2.0"
},
"devDependencies": {
"@babel/core": "^7.12.17",
"@babel/plugin-syntax-dynamic-import": "^7.8.3",
"@babel/preset-env": "^7.12.17",
"@babel/preset-react": "^7.12.13",
"babel-loader": "^8.2.2",
"babel-plugin-import": "^1.13.3",
"copy-webpack-plugin": "^7.0.0",
"css-loader": "^5.0.2",
"dotenv-webpack": "^6.0.0",
"eslint": "^7.20.0",
"eslint-config-airbnb": "^18.2.1",
"eslint-config-standard": "^16.0.2",
"eslint-plugin-import": "^2.22.1",
"eslint-plugin-react": "^7.22.0",
"html-webpack-plugin": "^5.2.0",
"less": "^4.1.1",
"less-loader": "^8.0.0",
"less-vars-to-js": "^1.3.0",
"serve": "^11.3.2",
"string-replace-loader": "^3.0.1",
"style-loader": "^2.0.0",
"url-loader": "^4.1.1",
"webpack": "^5.23.0",
"webpack-cli": "^4.5.0"
}
}
.babalrc
{
"presets": [
"@babel/preset-env",
"@babel/preset-react"
],
"plugins": [
[
"import",
{
"libraryName": "antd",
"style": true
}
]
],
}
and finaly here is the error details
