Skip to content

Commit be8982a

Browse files
committed
Test that library works after dist as well
1 parent 8d8b625 commit be8982a

File tree

6 files changed

+82
-44
lines changed

6 files changed

+82
-44
lines changed

.github/workflows/test.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424
node-version: ${{ matrix.node-version }}
2525
cache: "npm"
2626
- run: npm ci
27-
- run: npm run build:app
27+
- run: npm run build
2828
- id: e2e_tests
2929
run: npm run test:e2e
3030
- uses: actions/upload-artifact@v4

cypress/support/describeAll.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
export default function describeAll(title: string, fn: () => void) {
2-
for (const url of ["/model", "/no-model"]) {
2+
for (const url of ["/model", "/no-model", "/from-dist"]) {
33
describe(`${title} (${url})`, () => {
44
beforeEach(() => {
55
cy.visit(url);

package.json

+12-8
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,17 @@
33
"version": "0.1.0",
44
"type": "module",
55
"private": false,
6-
"description": "Lightweight component to generate a simply flipbook from a list of images.",
6+
"description": "Lightweight vue component to generate a simple flipbook from a list of images.",
77
"keywords": [
88
"flipbook",
9-
"digital catalog",
9+
"catalog",
10+
"catalogue",
11+
"component",
12+
"book",
13+
"page",
14+
"flip",
15+
"turn",
16+
"3d",
1017
"vue3"
1118
],
1219
"homepage": "https://github.com/flip-forge/vue-flip-forge#README",
@@ -18,14 +25,11 @@
1825
"author": "alexkiro",
1926
"scripts": {
2027
"dev": "vite",
21-
"build:app": "run-p type-check \"build-only:app {@}\" --",
22-
"build:lib": "run-p type-check \"build-only:lib {@}\" --",
23-
"preview": "vite preview",
28+
"build": "run-p type-check \"build-only {@}\" --",
2429
"test:unit": "vitest",
25-
"test:e2e": "start-server-and-test preview http://localhost:4173 'cypress run --e2e'",
30+
"test:e2e": "start-server-and-test 'vite dev --port 4173' http://localhost:4173 'cypress run --e2e'",
2631
"test:e2e:dev": "start-server-and-test 'vite dev --port 4173' http://localhost:4173 'cypress open --e2e'",
27-
"build-only:app": "vite build --mode app",
28-
"build-only:lib": "vite build --mode lib",
32+
"build-only": "vite build",
2933
"type-check": "vue-tsc --build --force",
3034
"lint": "eslint . --fix",
3135
"lint:check": "eslint .",

src/main.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,14 @@ import App from "./App.vue";
33
import { createRouter, createWebHistory } from "vue-router";
44
import WithModel from "@/views/WithModel.vue";
55
import WithoutModel from "@/views/WithoutModel.vue";
6+
const FromDist = () => import("@/views/FromDist.vue");
67

78
const router = createRouter({
89
history: createWebHistory(),
910
routes: [
10-
{ name: "with-model", path: "/", component: WithModel, alias: ["/model"] },
11-
{ name: "without-model", path: "/no-model", component: WithoutModel },
11+
{ path: "/", component: WithModel, alias: ["/model"] },
12+
{ path: "/no-model", component: WithoutModel },
13+
{ path: "/from-dist", component: FromDist },
1214
],
1315
});
1416

src/views/FromDist.vue

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<template>
2+
<component
3+
:is="flipForge"
4+
v-model="page"
5+
:pages="pages"
6+
:download-url="downloadUrl"
7+
/>
8+
</template>
9+
10+
<script lang="ts">
11+
import { defineAsyncComponent, defineComponent } from "vue";
12+
import { useRouteQuery } from "@vueuse/router";
13+
import downloadUrl from "@/assets/lorem_ipsum.pdf";
14+
15+
export default defineComponent({
16+
data() {
17+
return {
18+
downloadUrl,
19+
page: useRouteQuery("page", "0", {
20+
transform: Number,
21+
mode: "push",
22+
}),
23+
};
24+
},
25+
computed: {
26+
flipForge() {
27+
return defineAsyncComponent(() => import("../../"));
28+
},
29+
pages() {
30+
const result = [];
31+
for (let i = 1; i <= 10; i += 1) {
32+
result.push(`https://picsum.photos/seed/vue-flip-forge-${i}/768/400`);
33+
}
34+
return result;
35+
},
36+
},
37+
});
38+
</script>

vite.config.ts

+26-32
Original file line numberDiff line numberDiff line change
@@ -4,39 +4,33 @@ import vue from "@vitejs/plugin-vue";
44
import vueDevTools from "vite-plugin-vue-devtools";
55
import dtsPlugin from "vite-plugin-dts";
66

7-
export default defineConfig((config) => {
8-
let build = {};
9-
if (config.mode === "lib") {
10-
build = {
11-
lib: {
12-
entry: fileURLToPath(new URL("./src/index.ts", import.meta.url)),
13-
name: "Flip Forge",
14-
fileName: "vue-flip-forge",
15-
},
16-
rollupOptions: {
17-
external: ["vue"],
18-
output: {
19-
globals: {
20-
vue: "Vue",
21-
},
7+
export default defineConfig({
8+
plugins: [
9+
vue(),
10+
vueDevTools(),
11+
dtsPlugin({ tsconfigPath: "./tsconfig.lib.json" }),
12+
],
13+
resolve: {
14+
alias: {
15+
"@": fileURLToPath(new URL("./src", import.meta.url)),
16+
},
17+
},
18+
server: {
19+
port: 8080,
20+
},
21+
build: {
22+
lib: {
23+
entry: fileURLToPath(new URL("./src/index.ts", import.meta.url)),
24+
name: "Flip Forge",
25+
fileName: "vue-flip-forge",
26+
},
27+
rollupOptions: {
28+
external: ["vue"],
29+
output: {
30+
globals: {
31+
vue: "Vue",
2232
},
2333
},
24-
};
25-
}
26-
return {
27-
plugins: [
28-
vue(),
29-
vueDevTools(),
30-
dtsPlugin({ tsconfigPath: "./tsconfig.lib.json" }),
31-
],
32-
resolve: {
33-
alias: {
34-
"@": fileURLToPath(new URL("./src", import.meta.url)),
35-
},
36-
},
37-
server: {
38-
port: 8080,
3934
},
40-
build,
41-
};
35+
},
4236
});

0 commit comments

Comments
 (0)