Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

3.3 KB
Raw Blame
import { defineConfig } from 'vite-plus'
import { lintConfig } from './lint.config.ts'

const lintFiles = '*.{js,cjs,mjs,jsx,ts,cts,mts,tsx}'
const eslintFiles = '*.{json,jsonc,json5,md,yml,yaml}'
const formatOnlyFiles = '*.{mdx,css,scss,less,html,vue,svelte,gql,graphql,hbs,handlebars}'
const checkFix = 'vp check --fix --no-error-on-unmatched-pattern'
const formatFix = 'vp fmt --no-error-on-unmatched-pattern'
const eslintFix =
  'eslint --fix --pass-on-unpruned-suppressions --no-error-on-unmatched-pattern --no-warn-ignored'

const nonFrontendIgnores = [
  '.agents/**',
  '.devcontainer/**',
  '/*.md',
  'api/**',
  'codecov.yml',
  'depot.json',
  'dify-agent/**',
  'docker/**',
  'docs/**',
  'scripts/**/*',
  'sdks/php-client/**',
  'sdks/python-client/**',
]

const generatedIgnores = [
  // Preserve the retained Enterprise OpenAPI snapshots verbatim.
  'packages/contracts/generated/enterprise/openapi.gen.json',
  'packages/contracts/generated/enterprise-app-deploy/openapi.gen.json',
  '**/.next/**',
  '**/.vinext/**',
  '**/coverage/**',
  '**/dist/**',
  '**/storybook-static/**',
  'e2e/.auth/**',
  'e2e/cucumber-report/**',
  'eslint-suppressions.json',
  'oxlint-suppressions.json',
  'web/next/**',
  'web/next-env.d.ts',
  'web/public/embed.min.js',
  'web/public/pdf.worker.min.mjs',
  'web/public/vs/**',
  // Vendored Emojibase JSON is served verbatim.
  'web/public/emoji/emojibase-*/**',
]

const formatterUnstableInputs = ['web/app/components/develop/template/*.mdx']

export default defineConfig({
  lint: lintConfig,
  run: {
    tasks: {
      'check:cached': {
        command: ['vp check', 'eslint --concurrency=auto'],
        cache: {
          env: ['CI', 'NODE_ENV', 'TAILWIND_CANONICAL_CLASSES'],
          // Static checks have no artifacts to restore into the working tree.
          output: [],
        },
      },
    },
  },
  staged: {
    [lintFiles]: checkFix,
    [eslintFiles]: [eslintFix, formatFix],
    [formatOnlyFiles]: formatFix,
    '.vite-hooks/*': 'sh -n',
    'api/**/*.{py,pyi}': [
      // Format first so fixable long lines do not fail the API's E501 check.
      'uv run --locked --project api --dev ruff format --force-exclude',
      'uv run --locked --project api --dev ruff check --fix --force-exclude',
      'uv run --locked --project api --dev ruff format --force-exclude',
    ],
    'dify-agent/{src,examples,tests,docs}/**/*.py': [
      'uv run --locked --project dify-agent --dev ruff check --fix --force-exclude',
      'uv run --locked --project dify-agent --dev ruff format --force-exclude',
    ],
  },
  fmt: {
    ignorePatterns: [...nonFrontendIgnores, ...generatedIgnores, ...formatterUnstableInputs],
    singleQuote: true,
    semi: false,
    sortImports: {
      groups: [
        'type-import',
        ['type-parent', 'type-sibling', 'type-index', 'type-internal', 'type-subpath'],
        'value-builtin',
        'value-external',
        ['value-internal', 'value-subpath'],
        ['value-parent', 'value-sibling', 'value-index'],
        ['side_effect_style', 'side_effect'],
        'unknown',
      ],
      newlinesBetween: false,
      sortSideEffects: false,
    },
    sortPackageJson: true,
    sortTailwindcss: {
      functions: ['cn', 'clsx', 'cva', 'tw', 'twMerge'],
      preserveDuplicates: false,
      stylesheet: 'web/app/styles/globals.css',
    },
  },
})