@forsakringskassan/vite-lib-config 3.2.1 → 3.4.0
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.
- package/README.md +26 -1
- package/assets/index.html +1 -1
- package/dist/vite.config.cjs +30 -12
- package/dist/vite.config.d.ts +5 -0
- package/dist/vite.config.mjs +31 -14
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -84,7 +84,15 @@ Use `--help` to see full description.
|
|
|
84
84
|
|
|
85
85
|
### Dev-server
|
|
86
86
|
|
|
87
|
-
|
|
87
|
+
```json
|
|
88
|
+
{
|
|
89
|
+
"scripts": {
|
|
90
|
+
"start": "vite"
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
Create `src/local.{ts,mts,mjs,js}` exporting a single function `setup`:
|
|
88
96
|
|
|
89
97
|
```
|
|
90
98
|
import { createApp } from "vue";
|
|
@@ -100,3 +108,20 @@ export function setup(options: SetupOptions): void {
|
|
|
100
108
|
If the `setup` function is async (i.e. returns a `Promise`) it will be awaited before continuing.
|
|
101
109
|
|
|
102
110
|
Create `src/vite-dev/app.vue` containing the root component you want to serve as a development environment.
|
|
111
|
+
|
|
112
|
+
### Appending Plugins
|
|
113
|
+
|
|
114
|
+
If you need to use custom plugins in your library, remember to also include the default plugins, these will otherwise by overwritten.
|
|
115
|
+
|
|
116
|
+
#### `vite.config.ts`
|
|
117
|
+
|
|
118
|
+
```ts
|
|
119
|
+
import {
|
|
120
|
+
defineConfig,
|
|
121
|
+
defaultPlugins,
|
|
122
|
+
} from "@forsakringskassan/vite-lib-config/vite";
|
|
123
|
+
|
|
124
|
+
export default defineConfig({
|
|
125
|
+
plugins: [...defaultPlugins, myFancyPlugin],
|
|
126
|
+
});
|
|
127
|
+
```
|
package/assets/index.html
CHANGED
package/dist/vite.config.cjs
CHANGED
|
@@ -336,7 +336,7 @@ var require_dist = __commonJS({
|
|
|
336
336
|
"node_modules/@vitejs/plugin-vue/dist/index.cjs"(exports2, module2) {
|
|
337
337
|
"use strict";
|
|
338
338
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
339
|
-
var
|
|
339
|
+
var fs5 = require("node:fs");
|
|
340
340
|
var vite = require("vite");
|
|
341
341
|
var vue = require("vue");
|
|
342
342
|
var node_module = require("node:module");
|
|
@@ -348,7 +348,7 @@ var require_dist = __commonJS({
|
|
|
348
348
|
function _interopDefaultCompat(e) {
|
|
349
349
|
return e && typeof e === "object" && "default" in e ? e.default : e;
|
|
350
350
|
}
|
|
351
|
-
var fs__default = /* @__PURE__ */ _interopDefaultCompat(
|
|
351
|
+
var fs__default = /* @__PURE__ */ _interopDefaultCompat(fs5);
|
|
352
352
|
var path__default = /* @__PURE__ */ _interopDefaultCompat(path4);
|
|
353
353
|
var crypto__default = /* @__PURE__ */ _interopDefaultCompat(crypto);
|
|
354
354
|
var require$$0__default = /* @__PURE__ */ _interopDefaultCompat(require$$0);
|
|
@@ -4882,6 +4882,7 @@ var require_semver2 = __commonJS({
|
|
|
4882
4882
|
var vite_config_exports = {};
|
|
4883
4883
|
__export(vite_config_exports, {
|
|
4884
4884
|
apimockPlugin: () => import_apimock_express2.vitePlugin,
|
|
4885
|
+
defaultPlugins: () => defaultPlugins,
|
|
4885
4886
|
defineConfig: () => defineConfig,
|
|
4886
4887
|
vuePlugin: () => vuePlugin
|
|
4887
4888
|
});
|
|
@@ -4949,6 +4950,21 @@ function customMappingPlugin() {
|
|
|
4949
4950
|
// src/plugins/index-html-plugin.ts
|
|
4950
4951
|
var import_promises = __toESM(require("node:fs/promises"));
|
|
4951
4952
|
var import_node_path = __toESM(require("node:path"));
|
|
4953
|
+
|
|
4954
|
+
// src/utils/lookupFile.ts
|
|
4955
|
+
var import_node_fs = __toESM(require("node:fs"));
|
|
4956
|
+
var extensions = ["ts", "mts", "mjs", "js"];
|
|
4957
|
+
function lookupFile(nameWithoutExtension) {
|
|
4958
|
+
for (const extension of extensions) {
|
|
4959
|
+
const fileName = `${nameWithoutExtension}.${extension}`;
|
|
4960
|
+
if (import_node_fs.default.existsSync(fileName)) {
|
|
4961
|
+
return fileName;
|
|
4962
|
+
}
|
|
4963
|
+
}
|
|
4964
|
+
return `${nameWithoutExtension}.ts`;
|
|
4965
|
+
}
|
|
4966
|
+
|
|
4967
|
+
// src/plugins/index-html-plugin.ts
|
|
4952
4968
|
var templateFile = import_node_path.default.resolve(__dirname, "../assets/index.html");
|
|
4953
4969
|
var VIRTUAL_ENTRYPOINT = "index.html";
|
|
4954
4970
|
function isHtmlPage(url) {
|
|
@@ -4975,7 +4991,8 @@ function middleware(server) {
|
|
|
4975
4991
|
}
|
|
4976
4992
|
function indexHtmlPlugin() {
|
|
4977
4993
|
const templateData = {
|
|
4978
|
-
entrypoint: "/src/vite-dev/app.vue"
|
|
4994
|
+
entrypoint: "/src/vite-dev/app.vue",
|
|
4995
|
+
entrypointLocal: `/${lookupFile("src/local")}`
|
|
4979
4996
|
};
|
|
4980
4997
|
return {
|
|
4981
4998
|
name: "fk:virtual-entrypoint",
|
|
@@ -9672,8 +9689,8 @@ var PathScurryBase = class {
|
|
|
9672
9689
|
*
|
|
9673
9690
|
* @internal
|
|
9674
9691
|
*/
|
|
9675
|
-
constructor(cwd = process.cwd(), pathImpl, sep2, { nocase, childrenCacheSize = 16 * 1024, fs:
|
|
9676
|
-
this.#fs = fsFromOption(
|
|
9692
|
+
constructor(cwd = process.cwd(), pathImpl, sep2, { nocase, childrenCacheSize = 16 * 1024, fs: fs5 = defaultFS } = {}) {
|
|
9693
|
+
this.#fs = fsFromOption(fs5);
|
|
9677
9694
|
if (cwd instanceof URL || cwd.startsWith("file://")) {
|
|
9678
9695
|
cwd = (0, import_node_url.fileURLToPath)(cwd);
|
|
9679
9696
|
}
|
|
@@ -10231,8 +10248,8 @@ var PathScurryWin32 = class extends PathScurryBase {
|
|
|
10231
10248
|
/**
|
|
10232
10249
|
* @internal
|
|
10233
10250
|
*/
|
|
10234
|
-
newRoot(
|
|
10235
|
-
return new PathWin32(this.rootPath, IFDIR, void 0, this.roots, this.nocase, this.childrenCache(), { fs:
|
|
10251
|
+
newRoot(fs5) {
|
|
10252
|
+
return new PathWin32(this.rootPath, IFDIR, void 0, this.roots, this.nocase, this.childrenCache(), { fs: fs5 });
|
|
10236
10253
|
}
|
|
10237
10254
|
/**
|
|
10238
10255
|
* Return true if the provided path string is an absolute path
|
|
@@ -10260,8 +10277,8 @@ var PathScurryPosix = class extends PathScurryBase {
|
|
|
10260
10277
|
/**
|
|
10261
10278
|
* @internal
|
|
10262
10279
|
*/
|
|
10263
|
-
newRoot(
|
|
10264
|
-
return new PathPosix(this.rootPath, IFDIR, void 0, this.roots, this.nocase, this.childrenCache(), { fs:
|
|
10280
|
+
newRoot(fs5) {
|
|
10281
|
+
return new PathPosix(this.rootPath, IFDIR, void 0, this.roots, this.nocase, this.childrenCache(), { fs: fs5 });
|
|
10265
10282
|
}
|
|
10266
10283
|
/**
|
|
10267
10284
|
* Return true if the provided path string is an absolute path
|
|
@@ -11340,9 +11357,9 @@ var glob = Object.assign(glob_, {
|
|
|
11340
11357
|
glob.glob = glob;
|
|
11341
11358
|
|
|
11342
11359
|
// src/utils/read-json-file.ts
|
|
11343
|
-
var
|
|
11360
|
+
var import_node_fs2 = __toESM(require("node:fs"));
|
|
11344
11361
|
function readJsonFile(filename) {
|
|
11345
|
-
return JSON.parse(
|
|
11362
|
+
return JSON.parse(import_node_fs2.default.readFileSync(filename, "utf-8"));
|
|
11346
11363
|
}
|
|
11347
11364
|
|
|
11348
11365
|
// src/utils/detect-monorepo-packages.ts
|
|
@@ -11572,7 +11589,7 @@ var defaultConfig = {
|
|
|
11572
11589
|
sourcemap: true,
|
|
11573
11590
|
outDir: "dist/[custom-format]",
|
|
11574
11591
|
lib: {
|
|
11575
|
-
entry: "src/index
|
|
11592
|
+
entry: lookupFile("src/index"),
|
|
11576
11593
|
formats: ["es", "cjs"]
|
|
11577
11594
|
},
|
|
11578
11595
|
rollupOptions: {
|
|
@@ -11630,6 +11647,7 @@ function defineConfig(config) {
|
|
|
11630
11647
|
// Annotate the CommonJS export names for ESM import in node:
|
|
11631
11648
|
0 && (module.exports = {
|
|
11632
11649
|
apimockPlugin,
|
|
11650
|
+
defaultPlugins,
|
|
11633
11651
|
defineConfig,
|
|
11634
11652
|
vuePlugin
|
|
11635
11653
|
});
|
package/dist/vite.config.d.ts
CHANGED
package/dist/vite.config.mjs
CHANGED
|
@@ -4925,8 +4925,23 @@ function customMappingPlugin() {
|
|
|
4925
4925
|
}
|
|
4926
4926
|
|
|
4927
4927
|
// src/plugins/index-html-plugin.ts
|
|
4928
|
-
import
|
|
4928
|
+
import fs3 from "node:fs/promises";
|
|
4929
4929
|
import path2 from "node:path";
|
|
4930
|
+
|
|
4931
|
+
// src/utils/lookupFile.ts
|
|
4932
|
+
import fs2 from "node:fs";
|
|
4933
|
+
var extensions = ["ts", "mts", "mjs", "js"];
|
|
4934
|
+
function lookupFile(nameWithoutExtension) {
|
|
4935
|
+
for (const extension of extensions) {
|
|
4936
|
+
const fileName = `${nameWithoutExtension}.${extension}`;
|
|
4937
|
+
if (fs2.existsSync(fileName)) {
|
|
4938
|
+
return fileName;
|
|
4939
|
+
}
|
|
4940
|
+
}
|
|
4941
|
+
return `${nameWithoutExtension}.ts`;
|
|
4942
|
+
}
|
|
4943
|
+
|
|
4944
|
+
// src/plugins/index-html-plugin.ts
|
|
4930
4945
|
var templateFile = path2.resolve(__dirname, "../assets/index.html");
|
|
4931
4946
|
var VIRTUAL_ENTRYPOINT = "index.html";
|
|
4932
4947
|
function isHtmlPage(url) {
|
|
@@ -4953,7 +4968,8 @@ function middleware(server) {
|
|
|
4953
4968
|
}
|
|
4954
4969
|
function indexHtmlPlugin() {
|
|
4955
4970
|
const templateData = {
|
|
4956
|
-
entrypoint: "/src/vite-dev/app.vue"
|
|
4971
|
+
entrypoint: "/src/vite-dev/app.vue",
|
|
4972
|
+
entrypointLocal: `/${lookupFile("src/local")}`
|
|
4957
4973
|
};
|
|
4958
4974
|
return {
|
|
4959
4975
|
name: "fk:virtual-entrypoint",
|
|
@@ -4977,7 +4993,7 @@ function indexHtmlPlugin() {
|
|
|
4977
4993
|
transformIndexHtml: {
|
|
4978
4994
|
order: "pre",
|
|
4979
4995
|
async handler() {
|
|
4980
|
-
const content = await
|
|
4996
|
+
const content = await fs3.readFile(templateFile, "utf-8");
|
|
4981
4997
|
return content.replace(/{{([^}]+)}}/g, (match2, key) => {
|
|
4982
4998
|
return templateData[key.trim()] ?? match2;
|
|
4983
4999
|
});
|
|
@@ -5036,7 +5052,7 @@ function detectInternalDependencies(packages2, dependencies2) {
|
|
|
5036
5052
|
}
|
|
5037
5053
|
|
|
5038
5054
|
// src/utils/detect-monorepo-packages.ts
|
|
5039
|
-
import
|
|
5055
|
+
import fs5 from "fs";
|
|
5040
5056
|
import path4 from "node:path";
|
|
5041
5057
|
|
|
5042
5058
|
// node_modules/glob/node_modules/minimatch/dist/esm/index.js
|
|
@@ -9650,8 +9666,8 @@ var PathScurryBase = class {
|
|
|
9650
9666
|
*
|
|
9651
9667
|
* @internal
|
|
9652
9668
|
*/
|
|
9653
|
-
constructor(cwd = process.cwd(), pathImpl, sep2, { nocase, childrenCacheSize = 16 * 1024, fs:
|
|
9654
|
-
this.#fs = fsFromOption(
|
|
9669
|
+
constructor(cwd = process.cwd(), pathImpl, sep2, { nocase, childrenCacheSize = 16 * 1024, fs: fs6 = defaultFS } = {}) {
|
|
9670
|
+
this.#fs = fsFromOption(fs6);
|
|
9655
9671
|
if (cwd instanceof URL || cwd.startsWith("file://")) {
|
|
9656
9672
|
cwd = fileURLToPath(cwd);
|
|
9657
9673
|
}
|
|
@@ -10209,8 +10225,8 @@ var PathScurryWin32 = class extends PathScurryBase {
|
|
|
10209
10225
|
/**
|
|
10210
10226
|
* @internal
|
|
10211
10227
|
*/
|
|
10212
|
-
newRoot(
|
|
10213
|
-
return new PathWin32(this.rootPath, IFDIR, void 0, this.roots, this.nocase, this.childrenCache(), { fs:
|
|
10228
|
+
newRoot(fs6) {
|
|
10229
|
+
return new PathWin32(this.rootPath, IFDIR, void 0, this.roots, this.nocase, this.childrenCache(), { fs: fs6 });
|
|
10214
10230
|
}
|
|
10215
10231
|
/**
|
|
10216
10232
|
* Return true if the provided path string is an absolute path
|
|
@@ -10238,8 +10254,8 @@ var PathScurryPosix = class extends PathScurryBase {
|
|
|
10238
10254
|
/**
|
|
10239
10255
|
* @internal
|
|
10240
10256
|
*/
|
|
10241
|
-
newRoot(
|
|
10242
|
-
return new PathPosix(this.rootPath, IFDIR, void 0, this.roots, this.nocase, this.childrenCache(), { fs:
|
|
10257
|
+
newRoot(fs6) {
|
|
10258
|
+
return new PathPosix(this.rootPath, IFDIR, void 0, this.roots, this.nocase, this.childrenCache(), { fs: fs6 });
|
|
10243
10259
|
}
|
|
10244
10260
|
/**
|
|
10245
10261
|
* Return true if the provided path string is an absolute path
|
|
@@ -11318,15 +11334,15 @@ var glob = Object.assign(glob_, {
|
|
|
11318
11334
|
glob.glob = glob;
|
|
11319
11335
|
|
|
11320
11336
|
// src/utils/read-json-file.ts
|
|
11321
|
-
import
|
|
11337
|
+
import fs4 from "node:fs";
|
|
11322
11338
|
function readJsonFile(filename) {
|
|
11323
|
-
return JSON.parse(
|
|
11339
|
+
return JSON.parse(fs4.readFileSync(filename, "utf-8"));
|
|
11324
11340
|
}
|
|
11325
11341
|
|
|
11326
11342
|
// src/utils/detect-monorepo-packages.ts
|
|
11327
11343
|
function detectMonorepoPackages(...pkgPaths) {
|
|
11328
11344
|
for (const pkgPath of pkgPaths) {
|
|
11329
|
-
if (!
|
|
11345
|
+
if (!fs5.existsSync(pkgPath)) {
|
|
11330
11346
|
continue;
|
|
11331
11347
|
}
|
|
11332
11348
|
const rootDir = path4.dirname(pkgPath);
|
|
@@ -11552,7 +11568,7 @@ var defaultConfig = {
|
|
|
11552
11568
|
sourcemap: true,
|
|
11553
11569
|
outDir: "dist/[custom-format]",
|
|
11554
11570
|
lib: {
|
|
11555
|
-
entry: "src/index
|
|
11571
|
+
entry: lookupFile("src/index"),
|
|
11556
11572
|
formats: ["es", "cjs"]
|
|
11557
11573
|
},
|
|
11558
11574
|
rollupOptions: {
|
|
@@ -11609,6 +11625,7 @@ function defineConfig(config) {
|
|
|
11609
11625
|
}
|
|
11610
11626
|
export {
|
|
11611
11627
|
vitePlugin as apimockPlugin,
|
|
11628
|
+
defaultPlugins,
|
|
11612
11629
|
defineConfig,
|
|
11613
11630
|
vuePlugin2 as vuePlugin
|
|
11614
11631
|
};
|