Skip to content

Commit 8c6e783

Browse files
authored
Merge pull request #107 from Tal500/sveltekit
Sveltekit mega change, for better robustness
2 parents ca21a95 + d0792a4 commit 8c6e783

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+13346
-13298
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
node_modules
22
dist
33
storybook-static
4+
.svelte-kit
5+
package

.npmrc

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
auto-install-peers=true # TODO: Find the right peer deps instead of doing it automatically

.storybook/main.cjs

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// based on https://allandeutsch.com/notes/sveltekit-storybook-setup/
2+
3+
const fs = require('fs');
4+
const util = require('util');
5+
const readFile = (fileName) => util.promisify(fs.readFile)(fileName, 'utf8');
6+
7+
const path = require('path');
8+
9+
module.exports = {
10+
stories: ["../stories/**/*.stories.js"],
11+
addons: [
12+
"@storybook/addon-actions",
13+
"@storybook/addon-links",
14+
"@storybook/addon-storysource",
15+
"@storybook/addon-notes/register",
16+
"@storybook/addon-essentials",
17+
"@storybook/addon-svelte-csf"
18+
],
19+
"framework": "@storybook/svelte",
20+
"core": {
21+
"builder": "@storybook/builder-vite"
22+
},
23+
async viteFinal(config, { configType: _configType }) {
24+
config.resolve.alias = {
25+
$lib: path.resolve('./src/lib'),
26+
};
27+
28+
config.define = {
29+
...(config.define || {}),
30+
"process.env.__readme__": JSON.stringify(await readFile('README.md'))
31+
};
32+
33+
return config;
34+
},
35+
};

.storybook/main.js

-9
This file was deleted.

README.md

+43
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,49 @@ yarn add svelte-file-dropzone
8181

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

84+
## Build
85+
86+
### Setup
87+
88+
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:
89+
90+
```bash
91+
pnpm install
92+
pnpm sync
93+
```
94+
95+
### Build
96+
97+
To build the library, simply run `pnpm package`. The compiled output will be in the directory `package`.
98+
99+
### Storybook
100+
101+
You may view and build storybook examples of this library.
102+
103+
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.
104+
105+
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`.
106+
107+
Note: On some node environments, you might see the following error:
108+
109+
```
110+
node:internal/crypto/hash:67
111+
this[kHandle] = new _Hash(algorithm, xofLen);
112+
^
113+
114+
Error: error:0308010C:digital envelope routines::unsupported
115+
```
116+
117+
To overcome this, set manually in console the environment variable `NODE_OPTIONS=--openssl-legacy-provider`. See https://stackoverflow.com/a/69746937/2968864 for details.
118+
119+
### SvelteKit Example
120+
121+
We also have a modified version of the official SvelteKit basic example, for showing how to use it on SvelteKit.
122+
123+
To explore it, start a Vite development server by `pnpm dev`.
124+
125+
If you wish to have a full build of the SvelteKit example project, run `pnpm build`. To see the results, run `pnpm preview`.
126+
84127
## Credits
85128

86129
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).

examples/sveltekit-js/.eslintrc.cjs

-15
This file was deleted.

examples/sveltekit-js/.gitignore

-10
This file was deleted.

examples/sveltekit-js/.npmrc

-1
This file was deleted.

examples/sveltekit-js/.prettierrc

-6
This file was deleted.

examples/sveltekit-js/README.md

-38
This file was deleted.

examples/sveltekit-js/jsconfig.json

-10
This file was deleted.

0 commit comments

Comments
 (0)