0
Fork 0
mirror of https://github.com/penpot/penpot-plugins.git synced 2025-01-22 06:32:59 -05:00
penpot-plugins/tools/plugins/plugin-tasks.ts

57 lines
1.7 KiB
TypeScript
Raw Normal View History

2024-08-07 08:57:51 +02:00
import { CreateNodesV2, readJsonFile, logger } from '@nx/devkit';
import { createNodesFromFiles } from '@nx/devkit';
2024-06-06 15:42:52 +02:00
import { dirname } from 'path';
2024-08-07 08:57:51 +02:00
export const createNodesV2: CreateNodesV2 = [
2024-06-06 15:42:52 +02:00
'**/project.json',
2024-08-07 08:57:51 +02:00
async (configFiles, options, context) => {
return await createNodesFromFiles(
(configFile) => {
const projectConfiguration = readJsonFile(configFile);
2024-06-06 15:42:52 +02:00
2024-08-07 08:57:51 +02:00
if (
!projectConfiguration.tags ||
!projectConfiguration?.tags.includes('type:plugin') ||
!projectConfiguration?.targets.build
) {
return {};
}
2024-06-06 15:42:52 +02:00
2024-08-07 08:57:51 +02:00
const projectRoot = dirname(configFile);
2024-06-06 15:42:52 +02:00
2024-08-07 08:57:51 +02:00
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,
},
},
2024-06-06 15:42:52 +02:00
},
},
},
2024-08-07 08:57:51 +02:00
};
2024-06-06 15:42:52 +02:00
},
2024-08-07 08:57:51 +02:00
configFiles,
options,
context
);
2024-06-06 15:42:52 +02:00
},
];