@forsakringskassan/vite-lib-config 1.7.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/LICENSE.md +24 -0
- package/README.md +82 -0
- package/assets/index.html +30 -0
- package/bin/api-extractor.js +9 -0
- package/bin/build-vue-lib.js +9 -0
- package/dist/api-extractor.js +9802 -0
- package/dist/babel.config.d.ts +3 -0
- package/dist/babel.config.js +39 -0
- package/dist/cli.js +165 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.js +17 -0
- package/dist/tsdoc-metadata.json +11 -0
- package/dist/vite.config.d.ts +39 -0
- package/dist/vite.config.js +13100 -0
- package/package.json +59 -0
- package/vite.d.ts +1 -0
package/LICENSE.md
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright © 2024 Försäkringskassan
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person
|
|
6
|
+
obtaining a copy of this software and associated documentation
|
|
7
|
+
files (the “Software”), to deal in the Software without
|
|
8
|
+
restriction, including without limitation the rights to use,
|
|
9
|
+
copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
copies of the Software, and to permit persons to whom the
|
|
11
|
+
Software is furnished to do so, subject to the following
|
|
12
|
+
conditions:
|
|
13
|
+
|
|
14
|
+
The above copyright notice and this permission notice shall be
|
|
15
|
+
included in all copies or substantial portions of the Software.
|
|
16
|
+
|
|
17
|
+
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
|
|
18
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
|
19
|
+
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
20
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
|
21
|
+
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
22
|
+
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
23
|
+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
24
|
+
OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
# `@forsakringskassan/vite-lib-config`
|
|
2
|
+
|
|
3
|
+
Toolchain for building Vue framework libraries.
|
|
4
|
+
|
|
5
|
+
## Usage
|
|
6
|
+
|
|
7
|
+
### `babel.config.js`
|
|
8
|
+
|
|
9
|
+
```js
|
|
10
|
+
module.exports = {
|
|
11
|
+
presets: ["@forsakringskassan/vite-lib-config/babel"],
|
|
12
|
+
};
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
### `vite.config.ts`
|
|
16
|
+
|
|
17
|
+
```ts
|
|
18
|
+
import { defineConfig } from "@forsakringskassan/vite-lib-config/vite";
|
|
19
|
+
|
|
20
|
+
export default defineConfig();
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
In addition to the regular Vite configuration you can also pass the optional `fk` property:
|
|
24
|
+
|
|
25
|
+
```
|
|
26
|
+
export interface FKConfig {
|
|
27
|
+
/** path to component to mount by default (default `src/dev-vite/app.vue`) */
|
|
28
|
+
entrypoint?: string;
|
|
29
|
+
/** mocks to configure with apimock-express (default `[]`) */
|
|
30
|
+
mocks?: MockEntry[];
|
|
31
|
+
}
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
### `package.json`
|
|
35
|
+
|
|
36
|
+
```json
|
|
37
|
+
{
|
|
38
|
+
"scripts": {
|
|
39
|
+
"build": "fk-build-vue-lib"
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
### Optional: API Extractor
|
|
45
|
+
|
|
46
|
+
```diff
|
|
47
|
+
{
|
|
48
|
+
"scripts": {
|
|
49
|
+
"build": "fk-build-vue-lib",
|
|
50
|
+
+ "postbuild": "fk-api-extractor api-extractor.json",
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
Multiple files or globs can be given:
|
|
56
|
+
|
|
57
|
+
> fk-api-extractor api-extractor.\*.json
|
|
58
|
+
|
|
59
|
+
To fix global module augmentations use:
|
|
60
|
+
|
|
61
|
+
> fk-api-extractor --patch-augmentations
|
|
62
|
+
|
|
63
|
+
Use `--help` to see full description.
|
|
64
|
+
|
|
65
|
+
### Dev-server
|
|
66
|
+
|
|
67
|
+
Create `src/local.ts` exporting a single function `setup`:
|
|
68
|
+
|
|
69
|
+
```
|
|
70
|
+
import { createApp } from "vue";
|
|
71
|
+
import { type SetupOptions } from "@forsakringskassan/vite-lib-config";
|
|
72
|
+
|
|
73
|
+
export function setup(options: SetupOptions): void {
|
|
74
|
+
const { rootComponent, selector } = options;
|
|
75
|
+
const app = createApp(rootComponent);
|
|
76
|
+
app.mount(selector);
|
|
77
|
+
}
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
If the `setup` function is async (i.e. returns a `Promise`) it will be awaited before continuing.
|
|
81
|
+
|
|
82
|
+
Create `src/vite-dev/app.vue` containing the root component you want to serve as a development environment.
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8" />
|
|
5
|
+
<link rel="icon" href="/favicon.ico" />
|
|
6
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
7
|
+
<title>FKUI Vite development environment</title>
|
|
8
|
+
</head>
|
|
9
|
+
<body>
|
|
10
|
+
<div id="app"></div>
|
|
11
|
+
|
|
12
|
+
<script type="module">
|
|
13
|
+
import { setup } from "/src/local.ts";
|
|
14
|
+
import App from "{{ entrypoint }}";
|
|
15
|
+
|
|
16
|
+
const selector = "#app";
|
|
17
|
+
try {
|
|
18
|
+
await setup({
|
|
19
|
+
rootComponent: App,
|
|
20
|
+
selector,
|
|
21
|
+
});
|
|
22
|
+
} catch (err) {
|
|
23
|
+
console.error(err);
|
|
24
|
+
const pre = document.createElement("pre");
|
|
25
|
+
pre.innerText = err.stack ?? String(err);
|
|
26
|
+
document.querySelector(selector).replaceWith(pre);
|
|
27
|
+
}
|
|
28
|
+
</script>
|
|
29
|
+
</body>
|
|
30
|
+
</html>
|