Skip to content

Commit 94e5215

Browse files
committed
fix: fixed issue with engine not loading correctly, closes: #26
1 parent b113721 commit 94e5215

File tree

7 files changed

+57
-134
lines changed

7 files changed

+57
-134
lines changed

apps/vue3/src/components/Particles/Particles.vue

Lines changed: 0 additions & 66 deletions
This file was deleted.

apps/vue3/src/components/Particles/index.ts

Lines changed: 0 additions & 10 deletions
This file was deleted.

apps/vue3/src/main.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { createApp } from "vue";
2-
//import Particles from "vue3-particles";
3-
import Particles from "./components/Particles";
2+
import Particles from "vue3-particles";
43
import App from "./App.vue";
54
import router from "./router";
65

components/vue3-alt/src/components/Particles.vue

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,20 @@ export default defineComponent({
1717
props: {
1818
id: {
1919
type: String,
20-
required: true
20+
required: true,
2121
},
2222
options: {
23-
type: Object as PropType<IParticlesProps>
23+
type: Object as PropType<IParticlesProps>,
2424
},
2525
url: {
26-
type: String
26+
type: String,
2727
},
2828
particlesLoaded: {
29-
type: Function as PropType<(container: Container) => void>
29+
type: Function as PropType<(container: Container) => void>,
3030
},
3131
particlesInit: {
32-
type: Function as PropType<(engine: Engine) => Promise<void>>
33-
}
32+
type: Function as PropType<(engine: Engine) => Promise<void>>,
33+
},
3434
},
3535
mounted(): void {
3636
nextTick(async () => {
@@ -47,7 +47,7 @@ export default defineComponent({
4747
container = await tsParticles.load({
4848
id: this.id,
4949
url: this.url,
50-
options: this.options
50+
options: this.options,
5151
});
5252
5353
if (this.particlesLoaded && container) {
@@ -61,6 +61,6 @@ export default defineComponent({
6161
6262
container = undefined;
6363
}
64-
}
64+
},
6565
});
6666
</script>

components/vue3-alt/vite.config.ts

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -7,27 +7,27 @@ import dts from "vite-plugin-dts";
77

88
// https://vitejs.dev/config/
99
export default defineConfig({
10-
build: {
11-
lib: {
12-
entry: path.resolve(__dirname, "src/components/index.ts"),
13-
name: "particles.vue3",
14-
fileName: (format) => `particles.vue3.${format}.js`,
15-
},
16-
rollupOptions: {
17-
external: ["vue"],
18-
output: {
19-
// Provide global variables to use in the UMD build
20-
// Add external deps here
21-
globals: {
22-
vue: "Vue",
10+
build: {
11+
lib: {
12+
entry: path.resolve(__dirname, "src/components/index.ts"),
13+
name: "particles.vue3",
14+
fileName: format => `particles.vue3.${format}.js`,
15+
},
16+
rollupOptions: {
17+
external: ["vue", "tsparticles-engine"],
18+
output: {
19+
// Provide global variables to use in the UMD build
20+
// Add external deps here
21+
globals: {
22+
vue: "Vue",
23+
},
24+
},
2325
},
24-
},
2526
},
26-
},
27-
plugins: [vue(), vueJsx(), dts()],
28-
resolve: {
29-
alias: {
30-
"@": fileURLToPath(new URL("./src", import.meta.url)),
27+
plugins: [vue(), vueJsx(), dts()],
28+
resolve: {
29+
alias: {
30+
"@": fileURLToPath(new URL("./src", import.meta.url)),
31+
},
3132
},
32-
},
3333
});

components/vue3/src/components/Particles.vue

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,20 @@ export default defineComponent({
1717
props: {
1818
id: {
1919
type: String,
20-
required: true
20+
required: true,
2121
},
2222
options: {
23-
type: Object as PropType<IParticlesProps>
23+
type: Object as PropType<IParticlesProps>,
2424
},
2525
url: {
26-
type: String
26+
type: String,
2727
},
2828
particlesLoaded: {
29-
type: Function as PropType<(container: Container) => void>
29+
type: Function as PropType<(container: Container) => void>,
3030
},
3131
particlesInit: {
32-
type: Function as PropType<(engine: Engine) => Promise<void>>
33-
}
32+
type: Function as PropType<(engine: Engine) => Promise<void>>,
33+
},
3434
},
3535
mounted(): void {
3636
nextTick(async () => {
@@ -47,7 +47,7 @@ export default defineComponent({
4747
container = await tsParticles.load({
4848
id: this.id,
4949
url: this.url,
50-
options: this.options
50+
options: this.options,
5151
});
5252
5353
if (this.particlesLoaded && container) {
@@ -61,6 +61,6 @@ export default defineComponent({
6161
6262
container = undefined;
6363
}
64-
}
64+
},
6565
});
6666
</script>

components/vue3/vite.config.ts

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -7,27 +7,27 @@ import dts from "vite-plugin-dts";
77

88
// https://vitejs.dev/config/
99
export default defineConfig({
10-
build: {
11-
lib: {
12-
entry: path.resolve(__dirname, "src/components/index.ts"),
13-
name: "vue3-particles",
14-
fileName: (format) => `vue3-particles.${format}.js`,
15-
},
16-
rollupOptions: {
17-
external: ["vue"],
18-
output: {
19-
// Provide global variables to use in the UMD build
20-
// Add external deps here
21-
globals: {
22-
vue: "Vue",
10+
build: {
11+
lib: {
12+
entry: path.resolve(__dirname, "src/components/index.ts"),
13+
name: "vue3-particles",
14+
fileName: format => `vue3-particles.${format}.js`,
15+
},
16+
rollupOptions: {
17+
external: ["vue", "tsparticles-engine"],
18+
output: {
19+
// Provide global variables to use in the UMD build
20+
// Add external deps here
21+
globals: {
22+
vue: "Vue",
23+
},
24+
},
2325
},
24-
},
2526
},
26-
},
27-
plugins: [vue(), vueJsx(), dts()],
28-
resolve: {
29-
alias: {
30-
"@": fileURLToPath(new URL("./src", import.meta.url)),
27+
plugins: [vue(), vueJsx(), dts()],
28+
resolve: {
29+
alias: {
30+
"@": fileURLToPath(new URL("./src", import.meta.url)),
31+
},
3132
},
32-
},
3333
});

0 commit comments

Comments
 (0)