failed to build custom less files in `with-ant-design-less` sample with `target: serverless`
See original GitHub issueBug report
Describe the bug
In the case using target: 'serverless'
flag in next.config.js
, the with-ant-design-less sample code build failed.
$ yarn build
yarn run v1.17.3
$ next build
Creating an optimized production build ...
> Using external babel configuration
> Location: "/Users/bko/data/dev/_projects/next-with-ant-design-less-failed/.babelrc"
Compiled with warnings.
./node_modules/component-classes/index.js
Module not found: Can't resolve 'indexof' in '/Users/bko/data/dev/_projects/next-with-ant-design-less-failed/node_modules/component-classes'
> Build error occurred
TypeError: (0 , _styleChecker.default) is not a function
at Object.g5iu (/Users/bko/data/dev/_projects/next-with-ant-design-less-failed/.next/serverless/pages/index.js:37583:55)
at __webpack_require__ (/Users/bko/data/dev/_projects/next-with-ant-design-less-failed/.next/serverless/pages/index.js:23:31)
at Object.3PeW (/Users/bko/data/dev/_projects/next-with-ant-design-less-failed/.next/serverless/pages/index.js:3977:36)
at __webpack_require__ (/Users/bko/data/dev/_projects/next-with-ant-design-less-failed/.next/serverless/pages/index.js:23:31)
at Object.lbd2 (/Users/bko/data/dev/_projects/next-with-ant-design-less-failed/.next/serverless/pages/index.js:42120:36)
at __webpack_require__ (/Users/bko/data/dev/_projects/next-with-ant-design-less-failed/.next/serverless/pages/index.js:23:31)
at Module.ILaR (/Users/bko/data/dev/_projects/next-with-ant-design-less-failed/.next/serverless/pages/index.js:15153:18)
at __webpack_require__ (/Users/bko/data/dev/_projects/next-with-ant-design-less-failed/.next/serverless/pages/index.js:23:31)
at /Users/bko/data/dev/_projects/next-with-ant-design-less-failed/.next/serverless/pages/index.js:91:18
at Object.<anonymous> (/Users/bko/data/dev/_projects/next-with-ant-design-less-failed/.next/serverless/pages/index.js:94:10)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
To Reproduce
- Go to ‘https://github.com/bokuo-okubo/next-with-ant-design-less-failed’
yarn
- next => working fine
- next build => Error
(also in the case remove target: 'serverless'
flag, build works fine.)
Expected behavior
I tried to build with the check condition also options.dev flag, it works fine.
In the case of using target: 'serverless'
mode, config.externals
contain the amp-toolbox-optimizer
, so the something wrong around there.
Screenshots
- dump the option in the build time
System information
- OS: macOS, Mojave, Version 10.14.5
- Browser (if applies) [e.g. chrome, safari]
- next version: “9.0.2”
- package.json
-
{ "name": "next-with-ant-design-less-failed", "version": "0.1.0", "private": true, "scripts": { "dev": "node server.js", "build": "next build", "start": "cross-env NODE_ENV=production node server.js" }, "dependencies": { "antd": "^3.20.7", "babel-plugin-import": "^1.12.0", "cross-env": "^5.2.0", "css-animation": "^1.6.0", "express": "^4.17.1", "less": "^3.9.0", "less-vars-to-js": "^1.3.0", "next": "9.0.2", "react": "16.8.6", "react-dom": "16.8.6" }, "resolutions": { "css-animation": "1.5.0" }, "devDependencies": { "@zeit/next-less": "^1.0.1", "null-loader": "^3.0.0", "style-loader": "^0.23.1" } }
-
Additional context
Add any other context about the problem here.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:2
- Comments:16 (2 by maintainers)
Top Results From Across the Web
failed to build custom less files in `with-ant-design ... - GitHub
Bug report Describe the bug In the case using target: 'serverless' flag in next.config.js, the with-ant-design-less sample code build failed ...
Read more >Error while deploying NextJS on AWS for serverless framework
js. It's very simple. Just deploy your code to github, connect to your repo via Amplify and then allow it to build your...
Read more >warning: kite has been deprecated because it is not ... - You.com
Kite doesn't seem to be working with jupyterlab 3.0.16 at the moment. I had the same problem for a week and then I...
Read more >Multi-env Next.js app with AWS Amplify & Serverless
Each time we use the Serverless CLI to build our Serverless components, the framework will produce a .serverless folder next to our serverless....
Read more >Blog - Next.js 8
The serverless target will output a single lambda per page. This file is completely standalone and does not require any dependencies to run:....
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 FreeTop 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
Top GitHub Comments
Just found the solution, at the
next.confg.js
Change the regex toconst antStyles = /(antd\/.*?\/style).*(?<![.]js)$/;
then everything will work. Thestylechecker
file was being null-loaded and cause problems. The regex make sure to include files that dont end withjs
extensionHave the same issue with the repo provided. Not entirely sure why Typography from ant design is breaking the build. Removing it will resolve the issue but it’s not ideal