Skip to content

Sveltekit component library self hosting fonts issue #3408

Description

@vasilppetrov

Describe the bug

I'm trying to build svelte components lib with Svelte kit. I want to self host my fonts, so I have added them in my custom component "Theme" which exports my global styles and fonts.

Folder structure is:

Theme/
Theme.svelte
fonts/webfonts/custom_font.woff2
fonts/webfonts/custom_font.ttf
css/ fonts.css
  1. When I run the project with "npm run dev" , it is working in my demo page in routes/ index.svelte.
  2. When I run "npm run package", svelte generates folder "package" and there is my component and the fonts folder with its content, but the .woff2 file and .ttf are broken. When I create a new project and add the package to it, there is an error in the browser "Failed to decode downloaded font:". After I've replaced the generated .woff2 and .ttf files after "npm run package" with those that are in my lib folder, it works as expected.

Is there a way to tell Svelte kit to not processing or modifying the files in folder or in general to skip file types in project but add them to package after run the command.
I'm sure that there is way to achieve this and I'll be very thankful If someone helps me

Reproduction

<script>
	console.log('Theme initialized');
</script>

<div class="theme">
	<slot />
</div>

<style global lang="scss">
	// Adding global styles
	@import '../../styles/root';
	@import '../../styles/utilities';
	@import '../../styles/base';
	@import './fonts/css/fonts.css';
</style>

Logs

No response

System Info

System:
    OS: macOS Mojave 10.14.5
    CPU: (8) x64 Intel(R) Core(TM) i7-4770HQ CPU @ 2.20GHz
    Memory: 2.55 GB / 16.00 GB
    Shell: 3.2.57 - /bin/bash
  Binaries:
    Node: 14.15.5 - ~/.nvm/versions/node/v14.15.5/bin/node
    npm: 6.14.11 - ~/.nvm/versions/node/v14.15.5/bin/npm

Severity

annoyance

Additional Information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions