Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Including Assets in Build doesn't work (regression) #26900

Closed
1 of 4 tasks
ondrej-stanek-ozobot opened this issue Jul 11, 2024 · 5 comments
Closed
1 of 4 tasks

Including Assets in Build doesn't work (regression) #26900

ondrej-stanek-ozobot opened this issue Jul 11, 2024 · 5 comments

Comments

@ondrej-stanek-ozobot
Copy link
Contributor

Current Behavior

nrwl/nx 19.4.2 doesn't copy the assets specified explicitly in the app's project.json per documentation Including Assets in Your Build.

Expected Behavior

The assets listed in the "assets" section in the app's project.json should be copied to the dist folder on build.

GitHub Repo

No response

Steps to Reproduce

  1. initialize a new nx workspace:
npx -y create-nx-workspace@19.4.2 --appName copyTest --preset next --e2eTestRunner none --style css --nextSrcDir test_nx_19.4.2 --nxCloud skip .
  1. populate some dummy files to be copied:
test_nx_19.4.2$ mkdir -p path-to-my-project/src
test_nx_19.4.2$ touch path-to-my-project/readme.md
test_nx_19.4.2$ touch path-to-my-project/executors.json
test_nx_19.4.2$ touch path-to-my-project/src/some.js
  1. modify the apps/copyTest/project.json to contain the copy directives (per the documentation):
{
  "name": "copyTest",
  "$schema": "../../node_modules/nx/schemas/project-schema.json",
  "sourceRoot": "apps/copyTest",
  "projectType": "application",
  "tags": [],
  "// targets": "to see all targets run: nx show project nx_test --web",
  "targets": {
    "build": {
      "executor": "@nx/next:build",
      "outputs": ["{options.outputPath}"],
      "defaultConfiguration": "production",
      "options": {
        "outputPath": "dist/apps/copyTest",
          "assets": [ 
          // Copies all the markdown files at the root of the project to the root of the output bundle
          "path-to-my-project/*.md",
          {
            "input": "./path-to-my-project/src", // look in the src folder
            "glob": "**/!(*.ts)", // for any file (in any folder) that is not a typescript file
            "output": "./src" // put those files in the src folder of the output bundle
          },
          {
             "input": "./path-to-my-project", // look in the project folder
             "glob": "executors.json", // for the executors.json file
             "output": "." // put the file in the root of the output bundle
          }
        ]
      }
    }
  }
}
  1. build the app:
npx nx build copyTest
  1. list the contents of the build folder to verify if assets were copied:
test_nx_19.4.2$ ls -a dist/apps/copyTest/public/
.  ..  favicon.ico  .gitkeep

(as show above, assets readme.md, src/ and executors.json were not copied, which is a bug)

Note: The same steps are followed with nrwl/nx version 18.3.5 (replace the command in step 1. with npx -y create-nx-workspace@18.3.5 --appName copyTest --preset next --e2eTestRunner none --style css --nextSrcDir test-nx-18.3.5 --nxCloud skip .. Version 18.3.5 copies at least the src/some.js file (rules for files path-to-my-project/readme.md and path-to-my-project/executors.json has to be removed for the build to pass - but this is probably a different issue/bug or our misunderstanding of the documentation.

Per the reproduction steps above, we believe there is a regression in nrwl/nx version 19.

Nx Report

NX   Report complete - copy this into the issue template

Node   : 20.12.2
OS     : linux-x64
npm    : 10.5.0

nx                 : 19.4.2
@nx/js             : 19.4.2
@nx/jest           : 19.4.2
@nx/linter         : 19.4.2
@nx/eslint         : 19.4.2
@nx/workspace      : 19.4.2
@nx/devkit         : 19.4.2
@nx/eslint-plugin  : 19.4.2
@nx/next           : 19.4.2
@nx/react          : 19.4.2
@nrwl/tao          : 19.4.2
@nx/web            : 19.4.2
@nx/webpack        : 19.4.2
typescript         : 5.4.5
---------------------------------------
Registered Plugins:
@nx/next/plugin
@nx/jest/plugin
@nx/eslint/plugin

Failure Logs

No response

Package Manager Version

No response

Operating System

  • macOS
  • Linux
  • Windows
  • Other (Please specify)

Additional Information

No response

@podjames
Copy link

We are seeing the same issue in a production Next.js app built with nx after upgrading to nx version 19.4.2. Assets that were being copied into the build in /dist are now being omitted. The build is being built via Github Action on a runner using ubuntu-22.04.

Strangely we cannot replicate the same problem when building locally on an M1 Mac.

@Achaak
Copy link

Achaak commented Jul 15, 2024

I confirm, the regression appears in version 19.4.0.
I'm using node 20.13.1

@EmilioAiolfi
Copy link

EmilioAiolfi commented Jul 17, 2024

Same here with 19.4.2 version
I had to rollback to version 19.3.2

@zettlrobert
Copy link

Unfortunately my team encounters the same issue with 19.4.2 and 19.5.0

jaysoo pushed a commit that referenced this issue Aug 14, 2024
#27337)

<!-- Please make sure you have read the submission guidelines before
posting an PR -->
<!--
https://github.com/nrwl/nx/blob/master/CONTRIBUTING.md#-submitting-a-pr
-->

<!-- Please make sure that your commit message follows our format -->
<!-- Example: `fix(nx): must begin with lowercase` -->

<!-- If this is a particularly complex change or feature addition, you
can request a dedicated Nx release for this pull request branch. Mention
someone from the Nx team or the `@nrwl/nx-pipelines-reviewers` and they
will confirm if the PR warrants its own release for testing purposes,
and generate it for you if appropriate. -->

## Current Behavior
Assets are not copied to the dist folder after running @nx/next:build

## Expected Behavior
Assets should be copied to the dist folder after @nx/next:build

## Related Issue(s)
#26900

Fixes #
Fix the order, and wrong number of parameters call to
createWebpackConfig()

---------

Co-authored-by: Nicholas Cunningham <ndcunningham@gmail.com>
@ondrej-stanek-ozobot
Copy link
Contributor Author

The issue was fixed, we are now running nx version 19.6.4 with no problems. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants