Skip to content

Sveltekit mega change, for better robustness #107

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 16 commits into from
Oct 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
node_modules
dist
storybook-static
.svelte-kit
package
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
auto-install-peers=true # TODO: Find the right peer deps instead of doing it automatically
35 changes: 35 additions & 0 deletions .storybook/main.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// based on https://allandeutsch.com/notes/sveltekit-storybook-setup/

const fs = require('fs');
const util = require('util');
const readFile = (fileName) => util.promisify(fs.readFile)(fileName, 'utf8');

const path = require('path');

module.exports = {
stories: ["../stories/**/*.stories.js"],
addons: [
"@storybook/addon-actions",
"@storybook/addon-links",
"@storybook/addon-storysource",
"@storybook/addon-notes/register",
"@storybook/addon-essentials",
"@storybook/addon-svelte-csf"
],
"framework": "@storybook/svelte",
"core": {
"builder": "@storybook/builder-vite"
},
async viteFinal(config, { configType: _configType }) {
config.resolve.alias = {
$lib: path.resolve('./src/lib'),
};

config.define = {
...(config.define || {}),
"process.env.__readme__": JSON.stringify(await readFile('README.md'))
};

return config;
},
};
9 changes: 0 additions & 9 deletions .storybook/main.js

This file was deleted.

43 changes: 43 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,49 @@ yarn add svelte-file-dropzone

[Click here](https://github.com/thecodejack/svelte-file-dropzone/tree/master/stories/views) to view stories implementation

## Build

### Setup

To build from the source code, you'll need to use `pnpm` (if not installed already, install by `npm install -g pnpm`). To setup the environment, run:

```bash
pnpm install
pnpm sync
```

### Build

To build the library, simply run `pnpm package`. The compiled output will be in the directory `package`.

### Storybook

You may view and build storybook examples of this library.

To see then you can run a storybook development server by `pnpm storybook`. Runing a development server is much quicker and more responsive to changes comparing to a full build.

To generate the static HTML of the storybook (i.e. full build, e.g. for hosting in static server), run `pnpm build-storybook`. You may launch a local static HTML server by `pnpm sirv-storybook`.

Note: On some node environments, you might see the following error:

```
node:internal/crypto/hash:67
this[kHandle] = new _Hash(algorithm, xofLen);
^

Error: error:0308010C:digital envelope routines::unsupported
```

To overcome this, set manually in console the environment variable `NODE_OPTIONS=--openssl-legacy-provider`. See https://stackoverflow.com/a/69746937/2968864 for details.

### SvelteKit Example

We also have a modified version of the official SvelteKit basic example, for showing how to use it on SvelteKit.

To explore it, start a Vite development server by `pnpm dev`.

If you wish to have a full build of the SvelteKit example project, run `pnpm build`. To see the results, run `pnpm preview`.

## Credits

Component is reimplementation [react-dropzone](https://github.com/react-dropzone/react-dropzone). Complete credit goes to author and contributors of [react-dropzone](https://github.com/react-dropzone/react-dropzone).
Expand Down
15 changes: 0 additions & 15 deletions examples/sveltekit-js/.eslintrc.cjs

This file was deleted.

10 changes: 0 additions & 10 deletions examples/sveltekit-js/.gitignore

This file was deleted.

1 change: 0 additions & 1 deletion examples/sveltekit-js/.npmrc

This file was deleted.

6 changes: 0 additions & 6 deletions examples/sveltekit-js/.prettierrc

This file was deleted.

38 changes: 0 additions & 38 deletions examples/sveltekit-js/README.md

This file was deleted.

10 changes: 0 additions & 10 deletions examples/sveltekit-js/jsconfig.json

This file was deleted.

Loading