Closed SimplyComplexable closed 1 year ago
Same question here. Also affects examples like with-ant-design-less.
Seems like the team should port over all relevant packages under the @zeit organization to this monorepo before saying that all of @zeit is deprecated.
Would also love to see less supported directly in NextJS, but here's a config I've been using in the meantime instead of next-less.
const lessLoader = cssModules =>
[
!isServer && dev && 'extracted-loader',
!isServer && MiniCssExtractPlugin.loader,
{
loader: 'css-loader',
options: {
modules: {
mode: cssModules ? 'local' : 'global',
localIdentName: '[local]___[hash:base64:5]',
exportOnlyLocals: isServer,
},
importLoaders: 2,
},
},
{
loader: 'postcss-loader',
options: {
postcssOptions: {
plugins: ['autoprefixer'],
},
},
},
{
loader: 'less-loader',
options: { lessOptions: { javascriptEnabled: true } },
},
].filter(Boolean);
lessLoader
How to use lessLoader in next.config.js?
I'm using this plugin which works great for less files: https://github.com/SolidZORO/next-plugin-antd-less
lessLoader
How to use lessLoader in next.config.js?
You can do something like
// Use less with CSS modules.
config.module.rules.push({
test: /\.less$/,
use: lessLoader(true),
})
@SimplyComplexable I've added less support to next in #23185. Once that gets merged, we will not have to deal with all these work-arounds.
@digz6666 I just hooked up that plugin as well and it does load antd fine
But im unable to get my other less
files to be generated/included for the prod version of the app.
Is there additional config for importing less
files in project?
As of now I only have the base config that was in the readme for next-plugin-antd-less
@digz6666 I just hooked up that plugin as well and it does load antd fine But im unable to get my other
less
files to be generated/included for the prod version of the app. Is there additional config for importingless
files in project? As of now I only have the base config that was in the readme fornext-plugin-antd-less
You can do something like this:
import styles from './home.module.less'
const Home = () => {
return (
<>
<div className={styles.titleLeft}>
</div>
</>
)
}
export default Home
home.module.less file:
@import '~antd/lib/style/themes/default.less';
.titleLeft {
background-color: @border-color-base !important;
}
I have a custom index.less file where I'm overriding/making custom classes in the BEM convention so I need to import the entire custom index.less file.
I had to use a workaround that uses the less compiler to compile the less file into css and then import the generated index.css file instead since next supports regualr css out of the box.
package.json
{
"name": "messi-ops",
"version": "0.1.0",
"private": true,
"scripts": {
"dev": "concurrently \"next dev\" \"yarn build:styles\"", // run dev server AND watch for style changes
"build": "next build",
"start": "next start",
"build:styles": "less-watch-compiler ./styles ./styles index.less" // watch for any .less file changes in `styles` and output in index.css
},
"dependencies": {
"antd": "^4.15.0",
"cheerio": "^1.0.0-rc.5",
"next": "10.1.3",
"next-plugin-antd-less": "^0.3.0",
"react": "17.0.2",
"react-dom": "17.0.2"
},
"devDependencies": {
"babel-plugin-import": "^1.13.3",
"less-watch-compiler": "^1.14.6"
}
}
this just uses less-watch-compiler
to check for changes in a given folder and concurrently
which runs both the dev server and styles compiler at the same time for development
https://www.npmjs.com/package/less-watch-compiler https://www.npmjs.com/package/concurrently
Try this: https://github.com/elado/next-with-less
Please verify that your issue can be recreated with next@canary
.
please verify canary
label?We noticed the provided reproduction was using an older version of Next.js, instead of canary
.
The canary version of Next.js ships daily and includes all features and fixes that have not been released to the stable version yet. You can think of canary as a public beta. Some issues may already be fixed in the canary version, so please verify that your issue reproduces by running npm install next@canary
and test it in your project, using your reproduction steps.
If the issue does not reproduce with the canary
version, then it has already been fixed and this issue can be closed.
canary
?The safest way is to install next@canary
in your project and test it, but you can also search through closed Next.js issues for duplicates or check the Next.js releases.
canary
now?Next.js does not backport bug fixes to older versions of Next.js. Instead, we are trying to introduce only a minimal amount of breaking changes between major releases.
An issue with the please verify canary
that receives no meaningful activity (e.g. new comments that acknowledge verification against canary
) will be automatically closed and locked after 30 days.
If your issue has not been resolved in that time and it has been closed/locked, please open a new issue, with the required reproduction, using next@canary
.
Anyone experiencing the same issue is welcome to provide a minimal reproduction following the above steps. Furthermore, you can upvote the issue using the :+1: reaction on the topmost comment (please do not comment "I have the same issue" without repro steps). Then, we can sort issues by votes to prioritize.
We look into every Next.js issue and constantly monitor open issues for new comments.
However, sometimes we might miss one or two due to the popularity/high traffic of the repository. We apologize, and kindly ask you to refrain from tagging core maintainers, as that will usually not result in increased priority.
Upvoting issues to show your interest will help us prioritize and address them as quickly as possible. That said, every issue is important to us, and if an issue gets closed by accident, we encourage you to open a new one linking to the old issue and we will look into it.
This issue has been automatically closed because it wasn't verified against next@canary. If you think it was closed by accident, please leave a comment. If you are running into a similar issue, please open a new issue with a reproduction. Thank you.
This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.
What example does this report relate to?
with-next-less
What version of Next.js are you using?
10.0.8
What version of Node.js are you using?
14.4.0
What browser are you using?
Chrome
What operating system are you using?
macOS Big Sur
How are you deploying your application?
I'm not
Describe the Bug
The next-plugins repository has been deprecated, so I cannot create an issue in that repository, but this example is using a plugin from that repository. Is there a newer alternative to that plugin? I'm getting an error that's blocking me and I'm just not sure where to make the issue.
Expected Behavior
I just want to know the status of
next-less
.To Reproduce
I just want to know the status of
next-less
.