sapper

How can I manually compile a svelte component down to the final javascript and css that sapper/svelte produces?

北城以北 提交于 2021-01-24 07:11:44
问题 Our company produces an automation framework that is written in svelte/sapper. One feature is that developers can create custom ui widgets, currently using plain js/html/css and our client side api. These widgets are stored in the database and not on the file system. I think it would be a big plus to allow them to create widgets as svelte components since it contains all of the markup, js and css in one location and would give them all of the benefits of svelte's reactivity. I have gotten as

How do I load an external JS library in Svelte/Sapper?

大憨熊 提交于 2021-01-21 08:35:27
问题 I have been trying to load the ace editor (https://ace.c9.io/) into my Sapper application. I had success loading it in the script tag when I loaded it in a Sapper route, but when I am trying to do the same in a Svelte component which is again rendered by a route I get the error: ace is not defined This is the code I have, which is working fine if it is a Sapper route: <div id="editor"> def main(): return sum(range(1,100)) </div> <script src="https://pagecdn.io/lib/ace/1.4.6/ace.js" type="text

export typescript type in svelte file

偶尔善良 提交于 2021-01-04 05:33:36
问题 I want to export the type that I defined in one of my files and import it inside another file. export type myNewType = {name: string}; linter show me bellow error when I add export : Modifiers cannot appear here. I can make it work by creating a new ts file and import the type from it. I just want to know if there is a way to define type inside svelte file or not. Update: I use the sapper template and it will run without error but TS functionality not work and show me errors in vscode when

export typescript type in svelte file

China☆狼群 提交于 2021-01-04 05:32:06
问题 I want to export the type that I defined in one of my files and import it inside another file. export type myNewType = {name: string}; linter show me bellow error when I add export : Modifiers cannot appear here. I can make it work by creating a new ts file and import the type from it. I just want to know if there is a way to define type inside svelte file or not. Update: I use the sapper template and it will run without error but TS functionality not work and show me errors in vscode when

Failing to generate dynamic routes with Sapper export

邮差的信 提交于 2020-12-12 10:00:10
问题 I have a dynamic route: routes/artwork/[slug].svelte . All works great with npm run dev . But when I npm run export those dynamic slug routes are missing. I don't see them in the __sapper__/export , and the pages are missing as well when I uploaded to Netlify. Any clue how I might be able to fix that? Did I miss something obvious? 回答1: sapper export works by building your app, running it, then visiting / and recursively visiting every internal link it finds. For that reason, it has to be

How do you create routes with optional parameters in Sapper?

断了今生、忘了曾经 提交于 2020-08-07 06:18:21
问题 Let's say I have a /foo route. But sometimes people hit /foo with a language parameter: /fr/foo . And other times they might hit it with a language and a country: /ca/fr/foo So I need a routing table like [country]/[language]/foo [language]/foo /foo That all direct to the same page. Should I create a tree like this? src/routes └── [country] └── [language] └── foo.svelte If that's the answer then how do I direct [language]/foo to [country]/[language]/foo ? I don't see any optional params in

Svelte way for obtaining props values -in parent component and passing to a child component - after clicking on button

痞子三分冷 提交于 2020-06-29 04:34:14
问题 I'm learning svelte and sapper. I already have everything working correctly in my test app in one component but it is not optimal to build the whole app in one component. So my question here is about the svelte way of doing things. Keep this in mind while reading my question. It's a typical shopping app, page with products, button to add the product to the shopping cart and display the shopping cart and checkout button to finalize the user's purchase with the payment. My issue is about props

Svelte/Sapper.js - How to initialize store with localStorage data?

北城以北 提交于 2020-06-09 12:13:26
问题 I come from a React background but I'm switching to Svelte and Sapper for my next application in order to fight the massive bundle size that comes with React these days. However, I'm having trouble initializing Svelte's store with data retreived from localStorage. As per the Sapper docs (https://sapper.svelte.dev/docs#Getting_started), I created my project by running npx degit "sveltejs/sapper-template#rollup" my-app from the command line. I then installed the dependencies and removed the

sapper as static site generator

冷暖自知 提交于 2020-04-30 06:25:30
问题 I would like to use sapper as ssg. When I get data like so: <script context="module"> export function preload({ params, query }) { return this.fetch(`https://jsonplaceholder.typicode.com/posts`) .then(r => r.json()) .then(posts => { return {posts} }) } I can export the site to static. But on links the data still gets fetched from jsonplaceholder. Only on reload the data gets from the static folder. How to get all fetched data static? 回答1: So this can be a bit confusing in the beginning. To

Sapper session not setting properly in production build without page reload

做~自己de王妃 提交于 2020-03-03 09:16:51
问题 I'm working on a project using Sapper, and been struggling with something for a bit now – can't quite figure it out. I'm using Polka for my server (it was included with the sveltejs/sapper-template#rollup template so I went with it), and cookie-session for my session middleware. Here is my Polka configuration, where I seed session data also: polka() .use( compression({ threshold: 0 }), sirv('static', { dev }), cookieSession({ name: 'session', keys: [ '6e818055-d346-4fcb-bf56-4c7d54cb04ab',