@forsakringskassan/vite-lib-config 5.8.0 → 5.9.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -721,8 +721,8 @@ async function generateTsconfigLib(options) {
721
721
  compilerOptions: {
722
722
  types: testRunner === "jest" ? ["node", "jest", "vite/client"] : void 0,
723
723
  paths: {
724
- [`${name}/cypress`]: ["./src/cypress/index.ts"],
725
- [`${name}/selectors`]: ["./src/selectors/index.ts"],
724
+ [`${name}/cypress`]: options.enablePageobjects ? ["./src/cypress/index.ts"] : void 0,
725
+ [`${name}/selectors`]: options.enableSelectors ? ["./src/selectors/index.ts"] : void 0,
726
726
  [name]: ["./src/index.ts"]
727
727
  }
728
728
  }
@@ -738,8 +738,8 @@ async function generateTsconfigCypress(options) {
738
738
  ],
739
739
  compilerOptions: {
740
740
  paths: {
741
- [`${name}/cypress`]: ["./src/cypress/index.ts"],
742
- [`${name}/selectors`]: ["./src/selectors/index.ts"],
741
+ [`${name}/cypress`]: options.enablePageobjects ? ["./src/cypress/index.ts"] : void 0,
742
+ [`${name}/selectors`]: options.enableSelectors ? ["./src/selectors/index.ts"] : void 0,
743
743
  [name]: ["./src/index.ts"]
744
744
  }
745
745
  }
@@ -764,6 +764,18 @@ async function generateTsconfigPageobjects(options) {
764
764
  };
765
765
  return [boilerplate, await serializeJson(config)].join("\n\n");
766
766
  }
767
+ function generateViteConfig() {
768
+ const config = [
769
+ `import { defineConfig } from "@forsakringskassan/vite-lib-config/vite";`,
770
+ `import { defineTestConfig } from "@forsakringskassan/vitest-config-jsdom";`,
771
+ ``,
772
+ `export default defineConfig({`,
773
+ ` test: defineTestConfig(),`,
774
+ `});`
775
+ ].map((it) => `${it}
776
+ `).join("");
777
+ return [boilerplate, config].join("\n\n");
778
+ }
767
779
  async function readJsonFile(cwd, filename) {
768
780
  const filePath = path3.join(cwd, filename);
769
781
  const content = await fs3.readFile(filePath, "utf8");
@@ -825,7 +837,7 @@ async function findCypressConfigPath(cwd) {
825
837
  if (absolutePath) {
826
838
  return path3.relative(cwd, absolutePath).replaceAll("\\", "/");
827
839
  }
828
- return "cypress/tsconfig.json";
840
+ return "./cypress/tsconfig.json";
829
841
  }
830
842
  function shouldPrune(filename) {
831
843
  if (filename.startsWith("tsconfig.") && filename.endsWith(".json")) {
@@ -872,6 +884,7 @@ async function run(cwd, argv) {
872
884
  enableSelectors: Boolean(pkg.exports?.["./selectors"])
873
885
  };
874
886
  const generated = /* @__PURE__ */ new Map([
887
+ ["api-extractor.json", null],
875
888
  ["api-extractor.lib.json", generateApiExtractorLib(options)],
876
889
  ["api-extractor.cypress.json", generateApiExtractorCypress(options)],
877
890
  [
@@ -882,7 +895,10 @@ async function run(cwd, argv) {
882
895
  ["tsconfig.lib.json", generateTsconfigLib(options)],
883
896
  ["tsconfig.cypress.json", generateTsconfigCypress(options)],
884
897
  ["tsconfig.selectors.json", generateTsconfigSelectors(options)],
885
- ["tsconfig.pageobjects.json", generateTsconfigPageobjects(options)]
898
+ ["tsconfig.pageobjects.json", generateTsconfigPageobjects(options)],
899
+ ["vite.config.ts", null],
900
+ ["vite.config.mts", generateViteConfig()],
901
+ ["vitest.setup.ts", null]
886
902
  ]);
887
903
  console.group("Writing configuration files");
888
904
  console.log("API Extractor:", flagEnabled(options.enableApiExtractor));
@@ -924,6 +940,7 @@ export {
924
940
  generateTsconfigLib,
925
941
  generateTsconfigPageobjects,
926
942
  generateTsconfigSelectors,
943
+ generateViteConfig,
927
944
  run,
928
945
  updateBuildScripts
929
946
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@forsakringskassan/vite-lib-config",
3
- "version": "5.8.0",
3
+ "version": "5.9.1",
4
4
  "description": "Försäkringskassan toolchain to build libraries with Vite",
5
5
  "keywords": [
6
6
  "vite"