
/**
 * @param {"build" | "serve"} command
 * @param {import('../types/needleConfig').needleMeta | null | undefined} config
 * @param {import('../types').userSettings} userSettings
 * @returns {import('vite').Plugin}
 */
export function needleBuild(command, config, userSettings) {

    // TODO: need to set this when building a dist
    const isDeployOnlyBuild = config?.deployOnly === true;

    return {
        name: 'needle-build',
        config(config) {
            if (!config.build) {
                config.build = {};
            }
            if (isDeployOnlyBuild)
            {
                console.log("Deploy only build - will not empty output directory")
                config.build.emptyOutDir = false;
            }
        }
    }
}