question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

failed to build custom less files in `with-ant-design-less` sample with `target: serverless`

See original GitHub issue

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.

$ 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

  1. Go to ‘https://github.com/bokuo-okubo/next-with-ant-design-less-failed
  2. yarn
  3. next => working fine
  4. 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.

https://github.com/bokuo-okubo/next-with-ant-design-less-failed/blob/4ceee6c40d3a3e52ef52407715b3a056c03f9605/next.config.js#L34

In the case of using target: 'serverless' mode, config.externals contain the amp-toolbox-optimizer, so the something wrong around there.

Screenshots

Screenshot 2019-07-29 08 37 21


  • 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:closed
  • Created 4 years ago
  • Reactions:2
  • Comments:16 (2 by maintainers)

github_iconTop GitHub Comments

19reactions
ZhengYuTaycommented, Sep 3, 2019

Just found the solution, at the next.confg.js Change the regex to const antStyles = /(antd\/.*?\/style).*(?<![.]js)$/; then everything will work. The stylechecker file was being null-loaded and cause problems. The regex make sure to include files that dont end with js extension

2reactions
ZhengYuTaycommented, Aug 28, 2019

Have 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

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found