Replies: 5 comments 4 replies
-
|
Here is my solution for this: Put this file under // Copies custom assets from any folder to the target's "outputPath".
// Because "options.assets" doesn't allow copying from outside of "PROJECT.sourceRoot".
//
// Usage in workspace.json:
// "targets": {
// "build": {
// "executor": "@nrwl/node:build",
// "options": {
// "outputPath": "dist/apps/NESTJS_APP",
// "customAssets": [
// { "from": "dist/apps/smalljsapp/main.js", "toRelative": "assets/smalljsapp.min.js" }
// ],
// "webpackConfig": "tools/webpack/custom_assets_copier.js"
// },
// "configurations": {}
// }
// }
//
const CopyWebpackPlugin = require("copy-webpack-plugin");
const path = require("path");
module.exports = (config, context) => {
if (!context.options.customAssets) return config;
const patterns = context.options.customAssets.map((asset) => {
return {
from: path.resolve(context.options.root, asset.from),
to: asset.toRelative,
};
});
return { ...config, plugins: [...config.plugins, new CopyWebpackPlugin({ patterns })] };
}; |
Beta Was this translation helpful? Give feedback.
-
|
Shall we escalate this to a feature request? I don't see a need for the restriction. The whole point is that they're assests, not source code. Here's my solution: yarn add -DW patch-package |
Beta Was this translation helpful? Give feedback.
-
|
This limitation would make more sense if it was relative to |
Beta Was this translation helpful? Give feedback.
-
|
For what it's worth, you can avoid this error if you use the long form (object with |
Beta Was this translation helpful? Give feedback.
-
|
Do some executor like |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi nx team, great work on the project! Just started using it, and loving so far!
I have 2 projects:
nest- nestjs server,buttonjs- small JS projectI want
buttonjsproject to generatebutton.jsfile and copy it undernest's assets folder to serve from there.For that I'm trying to configure
nest's build target:But it doesn't allow me with this error:
asset path must start with the project source root:.Is there specific reason why there is this constraint? If yes, can we please document it in the source code and error message to make it more clear?
File: https://github.com/nrwl/nx/blob/master/packages/node/src/utils/normalize.ts
Beta Was this translation helpful? Give feedback.
All reactions