Closed luojinghui closed 2 months ago
hi, Is there any progress on the issue? @jaysoo
Hi @luojinghui, the @nx/vite:build
doesn't support assets
. Our philosophy is to rely on the underlying tool as much as possible, so in this case I would configure assets in vite.config.ts
instead. Maybe something like this would help: https://www.npmjs.com/package/vite-plugin-static-copy
I think we can add a plugin for this and configure vite.config.ts
automatically for JS libs. That would be a new feature.
I opened a PR for this. You can configure the plugin like:
// Copies all markdown files to dist
nxCopyAssetsPlugin(['*.md'])
In the meantime I think vite-plugin-static-copy
will still work.
@jaysoo
Thank you. Actually, I tried to solve the problem with the two plugins rollup-plugin-copy
and vite-plugin-static-copy
before. Unfortunately, they both had problems. It seemed that the problem was caused by the timing difference between nx build and plugin execution. In the end, the specified *.md
resource was not successfully copied to the destination.
So later I tried to execute a custom nodejs script after the nx build was completed to solve the problem, but it was not so elegant.
Thank you for providing another idea. I tried to upgrade the @nx/vite version to: @nx/vite@19.6.3, but did not find the corresponding plugin: @nx/vite/plugins/nx-copy-assets.plugin. Which version do I need to install?
This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context.
Current Behavior
I used
nx
+nx/js
+vite
to build a js library and configured the assets resources, but the build package did not include the resources in the assets, such as theREADME.md
file.Expected Behavior
When using
nx build
ornx release
, resources with assets can be correctly output, such asREADME.md
files, which is very important for npm packagesGitHub Repo
https://github.com/luojinghui/nx-project
Steps to Reproduce
pnpm install
nx run rtc-sdk:build
dist
directory to see if theREADME.md
file exists?Nx Report
Failure Logs
No response
Package Manager Version
No response
Operating System
Additional Information
if use
@nx/js:tsc
executor to build, it's no problem!No response