How to import less file globally with TSX file
See original GitHub issuePrerequisites
- Using yarn
- Using node 10.x
- Using an up-to-date
masterbranch - Using latest version of devtools. See wiki for howto update
- Link to stacktrace in a Gist (for bugs)
- For issue in production release, devtools output of
DEBUG_PROD=true yarn build && yarn start - Tried solutions mentioned in #400
Expected Behavior
Import ant.design styles globally and customize ui theme
I’m using ant.design UI
Current Behavior
Cannot import ant design less file globally
Possible Solution
Steps to Reproduce (for bugs)
1.Install related packages:
yarn add antd@3.26.15 less less-loader
2.less loader setting:
// webpack.config.renderer.prod.babel.js
{
test: /\.less$/,
use: [
{
loader: MiniCssExtractPlugin.loader
},
{
loader: 'css-loader',
options: {
modules: {
localIdentName:
'[name]__[local]__[hash:base64:5]'
},
importLoaders: 1,
sourceMap: true
}
},
{
loader: 'less-loader',
options: {
sourceMap: true,
javascriptEnabled: true
}
}
]
}
// webpack.config.renderer.dev.babel.js
{
test: /\.less$/,
use: [
{
loader: 'style-loader'
},
{
loader: 'css-loader',
options: {
modules: {
localIdentName:
'[name]__[local]__[hash:base64:5]'
},
sourceMap: true,
importLoaders: 1
}
},
{
loader: 'less-loader',
options: {
sourceMap: true,
javascriptEnabled: true
}
}
]
}
3.import antd theme from entrance file:
import 'antd/dist/antd.less';
4.Global import is not effective
Context
Your Environment
- Node version :v10.16.3
- Version or Branch used :v1.10
- Operating System and version :win10
- Link to your project :
Issue Analytics
- State:
- Created 3 years ago
- Comments:7 (2 by maintainers)
Top Results From Across the Web
How to require/import .less file in typescript file - Stack Overflow
If you just want to include the less file in your app, you can do import <path>/style.less . Webpack will then include (and...
Read more >How to add Global CSS / LESS styles to React with webpack
Import the styles.less global stylesheet into your main React entry file (e.g. /src/index.js or /src/index.jsx ) with the following line.
Read more >API - esbuild
To join a set of files together with esbuild, import them all into a single entry point file and bundle just that one...
Read more >Styling - Remix
Shared stylesheet. The first approach is very simple. Put them all in a shared.css file included in app/root.tsx .
Read more >Basic Features: Built-in CSS Support - Next.js
Next.js allows you to import CSS files from a JavaScript file. This is possible because Next.js extends the concept of import beyond JavaScript....
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

Actually it is working for me, but if you use css modules, class names are replaced with hashed names and you must import the css file into a variable and assign class names that variable. This is why I said this could be undesired for a global import, as usually you don’t want this when less/scss/css is global. Either try
or remove
modules: { localIdentName: '[name]__[local]__[hash:base64:5]' },from your loader config.@steveetm thx. it’s works when I remove css module config from less loader config