0
Fork 0
mirror of https://github.com/penpot/penpot-plugins.git synced 2025-01-09 00:10:12 -05:00
penpot-plugins/tools/plugins/plugin-tasks.ts
2024-06-07 10:11:20 +02:00

48 lines
1.4 KiB
TypeScript

import { CreateNodes, readJsonFile, logger } from '@nx/devkit';
import { dirname } from 'path';
export const createNodes: CreateNodes = [
'**/project.json',
async (configFilePath) => {
const projectConfiguration = readJsonFile(configFilePath);
if (
!projectConfiguration.tags ||
!projectConfiguration?.tags.includes('type:plugin') ||
!projectConfiguration?.targets.build
) {
return {};
}
const projectRoot = dirname(configFilePath);
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,
},
},
},
},
},
};
},
];