svelte-add icon indicating copy to clipboard operation
svelte-add copied to clipboard

[bootstrap] adder enhancement

Open bato3 opened this issue 3 years ago • 4 comments

(INFO: I'm first add scss, later bootstrap.)

# package.json

still they don't Install @popperjs/core

~~# src/app.scss, src/variables.scss~~

~~Should be @import "~bootstrap, because we have configured alias in vite, and VsCode resolve it to node_modules.~~ I don't know what i do on my work vork, but in home it stop works...

# src/app.ts (new file)

import { Dropdown as Dropdown, Offcanvas as Offcanvas } from 'bootstrap'; 

# src/routes/__layout.svelte

<script>
	import '../app.scss';
	import { browser } from '$app/env';
	import { onMount } from 'svelte';

	onMount(async () => {
		if (browser) {
			const firebaseClient = await import('../app');
		}
	});
</script>

<slot />

svelte.config.js

Missing import path from 'node:path';

bato3 avatar Dec 31 '21 15:12 bato3

What is this fixing?

babichjacob avatar Dec 31 '21 20:12 babichjacob

svelte.config.js

Missing import path from 'node:path';

We don't use path there.

babichjacob avatar Dec 31 '21 20:12 babichjacob

With path - it's my fault.

I'm trying to get alias resolve so that ~ points to node_modules. I forgot I copied vite.resolve and blamed you. xD

At the moment, I have a problem with run it in svelte-resolve.

The rest of the part deals with solving the JS import issue needed to run bootstrap, and this one contains references to window and documment.

In the svelte component you cannot use:

import { Dropdown as Dropdown, Offcanvas as Offcanvas } from 'bootstrap'; 

It will cause an error. Of course, you can link bootstrap.js from CDN, but that's not what I expect from svelte-add.

Therefore, I proposed a solution: onMount await import()

bato3 avatar Jan 02 '22 08:01 bato3

We have the option to include Sveltestrap for client-side interactivity based on Bootstrap's styles. Have you tried that and found that it's missing anything such that you need to fall back to regular Bootstrap JS?

babichjacob avatar Jan 02 '22 18:01 babichjacob

Closing because of no response

manuel3108 avatar Aug 20 '23 08:08 manuel3108