module.less not work
See original GitHub issueI want to use module.less in my app, but it doesn’t work, the style was not applied. please help, this is my craco.config.js file: craco-less version: 1.17.1
const CracoLessPlugin = require('craco-less');
module.exports = {
plugins: [
{
plugin: CracoLessPlugin,
options: {
lessLoaderOptions: {
lessOptions: {
modifyVars: { '@primary-color': '#004DE5' },
javascriptEnabled: true,
},
},
modifyLessRule: function(lessRule, _context) {
lessRule.test = /\.(module)\.(less)$/;
lessRule.exclude = /node_modules/;
return lessRule;
},
cssLoaderOptions: {
modules: { localIdentName: "[local]_[hash:base64:5]" }
}
}
},
],
};
and this is my tsx and style file, they were in the same dir.
AppHeader.tsx
import './AppHeader.module.less';
// import style file
AppHeader.module.less
.site_layout_header {
display: flex;
align-items: center;
height: 64px;
padding: 0 8px;
justify-content: space-between;
background-color: @primary-color;
}
.site_logo {
height: 58px;
margin-left: 0;
cursor: pointer;
object-fit: contain;
}
.site_info {
display: flex;
align-items: center;
}
.site_user {
margin-left: 8px;
color: white;
}
.logout_button {
margin-left: 8px;
color: #FFF;
padding: 0 20px;
border: 1px solid #16D0FF;
border-radius: 15px;
font-size: 12px;
}
Issue Analytics
- State:
- Created 3 years ago
- Comments:5
Top Results From Across the Web
webpack error in Cannot find module 'less' - Stack Overflow
This error happens because npm@3 does not resolve peerDependencies any more. npm install less less-loader is the way to go.
Read more >Magento 2 - Custom Module's _module.less file not updating
I'm working in developer mode. Any ideas? UPDATE. I checked Less files in custom modules but unfortunately this does not answer my question....
Read more >Features | Vite
Native ES imports do not support bare module imports like the following: ... warn you against the features that do not work with...
Read more >style-loader - webpack
Example with Locals (CSS Modules): ... Source maps do not work. ... for basic style-loader usage (similar to other file types, i.e. .lazy.less...
Read more >Working with CSS | Vue CLI
Please also be aware, as it's a native module, there may be compatibility issues vary on the OS and build environment. In that...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
ok, that work for me, but module less don’t save selectors hierarchy inside, how can that I correct? for example btn selector doesn’t will be to use(
https://stackoverflow.com/questions/66872491/reactjscratscarcoless-dont-correct-work-module-system-css/66877609#66877609