// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`@nx/vite:configuration library mode should add config for building library 1`] = `
"/// <reference types="vitest" />
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
import viteTsConfigPaths from 'vite-tsconfig-paths';
import dts from 'vite-plugin-dts';
import * as path from 'path';

export default defineConfig({
  cacheDir: '../node_modules/.vite/my-lib',

  plugins: [
    dts({
      entryRoot: 'src',
      tsConfigFilePath: path.join(__dirname, 'tsconfig.lib.json'),
      skipDiagnostics: true,
    }),
    react(),
    viteTsConfigPaths({
      root: '../',
    }),
  ],

  // Uncomment this if you are using workers.
  // worker: {
  //  plugins: [
  //    viteTsConfigPaths({
  //      root: '../',
  //    }),
  //  ],
  // },

  // Configuration for building your library.
  // See: https://vitejs.dev/guide/build.html#library-mode
  build: {
    lib: {
      // Could also be a dictionary or array of multiple entry points.
      entry: 'src/index.ts',
      name: 'my-lib',
      fileName: 'index',
      // Change this to the formats you want to support.
      // Don't forget to update your package.json as well.
      formats: ['es', 'cjs'],
    },
    rollupOptions: {
      // External packages that should not be bundled into your library.
      external: ['react', 'react-dom', 'react/jsx-runtime'],
    },
  },
});
"
`;

exports[`@nx/vite:configuration library mode should set up non buildable library correctly 1`] = `
"/// <reference types="vitest" />
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
import viteTsConfigPaths from 'vite-tsconfig-paths';
import dts from 'vite-plugin-dts';
import * as path from 'path';

export default defineConfig({
  cacheDir: '../../node_modules/.vite/react-lib-nonb-jest',

  plugins: [
    dts({
      entryRoot: 'src',
      tsConfigFilePath: path.join(__dirname, 'tsconfig.lib.json'),
      skipDiagnostics: true,
    }),
    react(),
    viteTsConfigPaths({
      root: '../../',
    }),
  ],

  // Uncomment this if you are using workers.
  // worker: {
  //  plugins: [
  //    viteTsConfigPaths({
  //      root: '../../',
  //    }),
  //  ],
  // },

  // Configuration for building your library.
  // See: https://vitejs.dev/guide/build.html#library-mode
  build: {
    lib: {
      // Could also be a dictionary or array of multiple entry points.
      entry: 'src/index.ts',
      name: 'react-lib-nonb-jest',
      fileName: 'index',
      // Change this to the formats you want to support.
      // Don't forget to update your package.json as well.
      formats: ['es', 'cjs'],
    },
    rollupOptions: {
      // External packages that should not be bundled into your library.
      external: ['react', 'react-dom', 'react/jsx-runtime'],
    },
  },

  test: {
    globals: true,
    cache: {
      dir: '../../node_modules/.vitest',
    },
    environment: 'jsdom',
    include: ['src/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],
  },
});
"
`;

exports[`@nx/vite:configuration library mode should set up non buildable library correctly 2`] = `
"{
  "projects": {
    "react-lib-nonb-jest": {
      "name": "react-lib-nonb-jest",
      "$schema": "../../node_modules/nx/schemas/project-schema.json",
      "root": "libs/react-lib-nonb-jest",
      "sourceRoot": "libs/react-lib-nonb-jest/src",
      "projectType": "library",
      "targets": {
        "lint": {
          "executor": "@nx/linter:eslint",
          "outputs": ["{options.outputFile}"],
          "options": {
            "lintFilePatterns": [
              "libs/react-lib-nonb-jest/**/*.{ts,tsx,js,jsx}"
            ]
          }
        },
        "test": {
          "executor": "@nx/jest:jest",
          "outputs": ["{workspaceRoot}/coverage/{projectRoot}"],
          "options": {
            "jestConfig": "libs/react-lib-nonb-jest/jest.config.ts",
            "passWithNoTests": true
          }
        }
      },
      "tags": []
    }
  }
}
"
`;

exports[`@nx/vite:configuration library mode should set up non buildable library which already has vite.config.ts correctly 1`] = `
"import dts from 'vite-plugin-dts';
import * as path from 'path';
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
import viteTsConfigPaths from 'vite-tsconfig-paths';

export default defineConfig({
  // Configuration for building your library.
  // See: https://vitejs.dev/guide/build.html#library-mode
  cacheDir: '../../node_modules/.vite/react-lib-nonb-vitest',
  build: {
    lib: {
      // Could also be a dictionary or array of multiple entry points.
      entry: 'src/index.ts',
      name: 'react-lib-nonb-vitest',
      fileName: 'index',
      // Change this to the formats you want to support.
      // Don't forget to update your package.json as well.
      formats: ['es', 'cjs'],
    },
    rollupOptions: {
      // External packages that should not be bundled into your library.
      external: ['react', 'react-dom', 'react/jsx-runtime'],
    },
  },
  plugins: [
    ...[
      react(),
      viteTsConfigPaths({
        root: '../../',
      }),
    ],
    dts({
      entryRoot: 'src',
      tsConfigFilePath: path.join(__dirname, 'tsconfig.lib.json'),
      skipDiagnostics: true,
    }),
  ],

  test: {
    globals: true,
    cache: {
      dir: '../../node_modules/.vitest',
    },
    environment: 'jsdom',
    include: ['src/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],
  },
});
"
`;

exports[`@nx/vite:configuration library mode should set up non buildable library which already has vite.config.ts correctly 2`] = `
"{
  "projects": {
    "react-lib-nonb-vitest": {
      "name": "react-lib-nonb-vitest",
      "$schema": "../../node_modules/nx/schemas/project-schema.json",
      "root": "libs/react-lib-nonb-vitest",
      "sourceRoot": "libs/react-lib-nonb-vitest/src",
      "projectType": "library",
      "targets": {
        "lint": {
          "executor": "@nx/linter:eslint",
          "outputs": ["{options.outputFile}"],
          "options": {
            "lintFilePatterns": [
              "libs/react-lib-nonb-vitest/**/*.{ts,tsx,js,jsx}"
            ]
          }
        },
        "test": {
          "executor": "@nx/vite:test",
          "outputs": ["{projectRoot}/coverage"],
          "options": {
            "passWithNoTests": true,
            "reportsDirectory": "{workspaceRoot}/coverage/{projectRoot}"
          }
        }
      },
      "tags": []
    }
  }
}
"
`;

exports[`@nx/vite:configuration transform React app to use Vite by providing custom targets transform React app if supported executor is provided should transform workspace.json project config 1`] = `
"{
  "projects": {
    "my-test-mixed-react-app": {
      "name": "my-test-mixed-react-app",
      "$schema": "../../node_modules/nx/schemas/project-schema.json",
      "root": "apps/my-test-mixed-react-app",
      "sourceRoot": "apps/my-test-mixed-react-app/src",
      "projectType": "application",
      "targets": {
        "invalid-build": {
          "executor": "@nx/js:tsc",
          "outputs": ["{options.outputPath}"]
        },
        "valid-build": {
          "executor": "@nx/webpack:webpack",
          "outputs": ["{options.outputPath}"]
        },
        "serve": {
          "executor": "@nx/webpack:dev-server",
          "defaultConfiguration": "development",
          "options": {
            "buildTarget": "my-test-mixed-react-app:build",
            "hmr": true
          },
          "configurations": {
            "development": {
              "buildTarget": "my-test-mixed-react-app:build:development"
            },
            "production": {
              "buildTarget": "my-test-mixed-react-app:build:production",
              "hmr": false
            }
          }
        },
        "lint": {
          "executor": "@nx/linter:eslint",
          "outputs": ["{options.outputFile}"],
          "options": {
            "lintFilePatterns": [
              "apps/my-test-mixed-react-app/**/*.{ts,tsx,js,jsx}"
            ]
          }
        },
        "test": {
          "executor": "@nx/jest:jest",
          "outputs": ["{workspaceRoot}/coverage/{projectRoot}"],
          "options": {
            "jestConfig": "apps/my-test-mixed-react-app/jest.config.ts",
            "passWithNoTests": true
          }
        }
      },
      "tags": []
    }
  }
}
"
`;

exports[`@nx/vite:configuration transform React app to use Vite should create vite.config file at the root of the app 1`] = `
"/// <reference types="vitest" />
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
import viteTsConfigPaths from 'vite-tsconfig-paths';

export default defineConfig({
  cacheDir: '../../node_modules/.vite/my-test-react-app',

  server: {
    port: 4200,
    host: 'localhost',
  },

  preview: {
    port: 4300,
    host: 'localhost',
  },

  plugins: [
    react(),
    viteTsConfigPaths({
      root: '../../',
    }),
  ],

  // Uncomment this if you are using workers.
  // worker: {
  //  plugins: [
  //    viteTsConfigPaths({
  //      root: '../../',
  //    }),
  //  ],
  // },
});
"
`;

exports[`@nx/vite:configuration transform React app to use Vite should move index.html to the root of the project 1`] = `
"<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8" />
    <title>My Test React App</title>
    <base href="/" />

    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <link rel="icon" type="image/x-icon" href="favicon.ico" />
  </head>
  <body>
    <div id="root"></div>
    <script type="module" src="/src/main.tsx"></script>
  </body>
</html>
"
`;

exports[`@nx/vite:configuration transform React app to use Vite should transform workspace.json project config 1`] = `
"{
  "projects": {
    "my-test-react-app": {
      "name": "my-test-react-app",
      "$schema": "../../node_modules/nx/schemas/project-schema.json",
      "root": "apps/my-test-react-app",
      "sourceRoot": "apps/my-test-react-app/src",
      "projectType": "application",
      "targets": {
        "build": {
          "executor": "@nx/webpack:webpack",
          "outputs": ["{options.outputPath}"],
          "defaultConfiguration": "production",
          "options": {
            "compiler": "babel",
            "outputPath": "dist/apps/my-test-react-app",
            "index": "apps/my-test-react-app/src/index.html",
            "baseHref": "/",
            "main": "apps/my-test-react-app/src/main.tsx",
            "polyfills": "apps/my-test-react-app/src/polyfills.ts",
            "tsConfig": "apps/my-test-react-app/tsconfig.app.json",
            "assets": [
              "apps/my-test-react-app/src/favicon.ico",
              "apps/my-test-react-app/src/assets"
            ],
            "styles": ["apps/my-test-react-app/src/styles.css"],
            "scripts": [],
            "webpackConfig": "@nx/react/plugins/webpack"
          },
          "configurations": {
            "development": {
              "extractLicenses": false,
              "optimization": false,
              "sourceMap": true,
              "vendorChunk": true
            },
            "production": {
              "fileReplacements": [
                {
                  "replace": "apps/my-test-react-app/src/environments/environment.ts",
                  "with": "apps/my-test-react-app/src/environments/environment.prod.ts"
                }
              ],
              "optimization": true,
              "outputHashing": "all",
              "sourceMap": false,
              "namedChunks": false,
              "extractLicenses": true,
              "vendorChunk": false
            }
          }
        },
        "serve": {
          "executor": "@nx/webpack:dev-server",
          "defaultConfiguration": "development",
          "options": {
            "buildTarget": "my-test-react-app:build",
            "hmr": true
          },
          "configurations": {
            "development": {
              "buildTarget": "my-test-react-app:build:development"
            },
            "production": {
              "buildTarget": "my-test-react-app:build:production",
              "hmr": false
            }
          }
        },
        "lint": {
          "executor": "@nx/linter:eslint",
          "outputs": ["{options.outputFile}"],
          "options": {
            "lintFilePatterns": ["apps/my-test-react-app/**/*.{ts,tsx,js,jsx}"]
          }
        },
        "test": {
          "executor": "@nx/jest:jest",
          "outputs": ["{workspaceRoot}/coverage/{projectRoot}"],
          "options": {
            "jestConfig": "apps/my-test-react-app/jest.config.ts",
            "passWithNoTests": true
          }
        }
      },
      "tags": []
    }
  }
}
"
`;

exports[`@nx/vite:configuration transform Web app to use Vite should create vite.config file at the root of the app 1`] = `
"/// <reference types="vitest" />
import { defineConfig } from 'vite';

import viteTsConfigPaths from 'vite-tsconfig-paths';

export default defineConfig({
  cacheDir: '../../node_modules/.vite/my-test-web-app',

  server: {
    port: 4200,
    host: 'localhost',
  },

  preview: {
    port: 4300,
    host: 'localhost',
  },

  plugins: [
    viteTsConfigPaths({
      root: '../../',
    }),
  ],

  // Uncomment this if you are using workers.
  // worker: {
  //  plugins: [
  //    viteTsConfigPaths({
  //      root: '../../',
  //    }),
  //  ],
  // },
});
"
`;

exports[`@nx/vite:configuration transform Web app to use Vite should move index.html to the root of the project 1`] = `
"<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8" />
    <title>WebappPure</title>
    <base href="/" />

    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <link rel="icon" type="image/x-icon" href="favicon.ico" />
  </head>
  <body>
    <workspace-root></workspace-root>
    <script type="module" src="/src/main.ts"></script>
  </body>
</html>
"
`;

exports[`@nx/vite:configuration transform Web app to use Vite should transform workspace.json project config 1`] = `
"{
  "projects": {
    "my-test-web-app": {
      "name": "my-test-web-app",
      "$schema": "../../node_modules/nx/schemas/project-schema.json",
      "projectType": "application",
      "root": "apps/my-test-web-app",
      "sourceRoot": "apps/my-test-web-app/src",
      "tags": [],
      "targets": {
        "build": {
          "executor": "@nx/webpack:webpack",
          "outputs": ["{options.outputPath}"],
          "defaultConfiguration": "production",
          "options": {
            "outputPath": "dist/apps/my-test-web-app",
            "compiler": "babel",
            "main": "apps/my-test-web-app/src/main.ts",
            "tsConfig": "apps/my-test-web-app/tsconfig.app.json",
            "assets": [
              "apps/my-test-web-app/src/favicon.ico",
              "apps/my-test-web-app/src/assets"
            ],
            "index": "apps/my-test-web-app/src/index.html",
            "baseHref": "/",
            "polyfills": "apps/my-test-web-app/src/polyfills.ts",
            "styles": ["apps/my-test-web-app/src/styles.css"],
            "scripts": []
          },
          "configurations": {
            "production": {
              "optimization": true,
              "outputHashing": "all",
              "sourceMap": false,
              "namedChunks": false,
              "extractLicenses": true,
              "vendorChunk": false,
              "fileReplacements": [
                {
                  "replace": "apps/my-test-web-app/src/environments/environment.ts",
                  "with": "apps/my-test-web-app/src/environments/environment.prod.ts"
                }
              ]
            }
          }
        },
        "serve": {
          "executor": "@nx/webpack:dev-server",
          "options": {
            "buildTarget": "my-test-web-app:build"
          },
          "configurations": {
            "production": {
              "buildTarget": "my-test-web-app:build:production"
            }
          }
        },
        "lint": {
          "executor": "@nx/linter:eslint",
          "outputs": ["{options.outputFile}"],
          "options": {
            "lintFilePatterns": ["apps/my-test-web-app/**/*.ts"]
          }
        },
        "test": {
          "executor": "@nx/jest:jest",
          "outputs": ["{workspaceRoot}/coverage/{projectRoot}"],
          "options": {
            "jestConfig": "apps/my-test-web-app/jest.config.ts",
            "passWithNoTests": true
          }
        }
      }
    }
  }
}
"
`;

exports[`@nx/vite:configuration vitest should create a vitest configuration if "includeVitest" is true 1`] = `
"/// <reference types="vitest" />
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
import viteTsConfigPaths from 'vite-tsconfig-paths';

export default defineConfig({
  cacheDir: '../../node_modules/.vite/my-test-react-app',

  server: {
    port: 4200,
    host: 'localhost',
  },

  preview: {
    port: 4300,
    host: 'localhost',
  },

  plugins: [
    react(),
    viteTsConfigPaths({
      root: '../../',
    }),
  ],

  // Uncomment this if you are using workers.
  // worker: {
  //  plugins: [
  //    viteTsConfigPaths({
  //      root: '../../',
  //    }),
  //  ],
  // },

  test: {
    globals: true,
    cache: {
      dir: '../../node_modules/.vitest',
    },
    environment: 'jsdom',
    include: ['src/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],
  },
});
"
`;
