mirror of
https://github.com/penpot/penpot-plugins.git
synced 2025-01-06 14:50:21 -05:00
56 lines
1.7 KiB
TypeScript
56 lines
1.7 KiB
TypeScript
import { CreateNodesV2, readJsonFile, logger } from '@nx/devkit';
|
|
import { createNodesFromFiles } from '@nx/devkit';
|
|
import { dirname } from 'path';
|
|
|
|
export const createNodesV2: CreateNodesV2 = [
|
|
'**/project.json',
|
|
async (configFiles, options, context) => {
|
|
return await createNodesFromFiles(
|
|
(configFile) => {
|
|
const projectConfiguration = readJsonFile(configFile);
|
|
|
|
if (
|
|
!projectConfiguration.tags ||
|
|
!projectConfiguration?.tags.includes('type:plugin') ||
|
|
!projectConfiguration?.targets.build
|
|
) {
|
|
return {};
|
|
}
|
|
|
|
const projectRoot = dirname(configFile);
|
|
|
|
return {
|
|
projects: {
|
|
[projectRoot]: {
|
|
root: projectRoot,
|
|
targets: {
|
|
init: {
|
|
executor: 'nx:run-commands',
|
|
options: {
|
|
command: `nx run-many --parallel --targets=buildPlugin,serve --projects=${projectConfiguration.name} --watch`,
|
|
},
|
|
},
|
|
buildPlugin: {
|
|
executor: '@nx/esbuild:esbuild',
|
|
outputs: ['{options.outputPath}'],
|
|
options: {
|
|
minify: true,
|
|
outputPath: `${projectConfiguration.sourceRoot}/assets/`,
|
|
main: `${projectConfiguration.sourceRoot}/plugin.ts`,
|
|
tsConfig: `${projectRoot}/tsconfig.plugin.json`,
|
|
generatePackageJson: false,
|
|
format: ['esm'],
|
|
deleteOutputPath: false,
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
};
|
|
},
|
|
configFiles,
|
|
options,
|
|
context
|
|
);
|
|
},
|
|
];
|