Skip to content

added vite example #2

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
24 changes: 24 additions & 0 deletions vite/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

node_modules
dist
dist-ssr
*.local

# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
27 changes: 27 additions & 0 deletions vite/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Vite Example

This project shows you how to get started with Dropzone and vite. It also contains a method for setting extra response headers:
- `Cross-Origin-Embedder-Policy: require-corp`
- `Cross-Origin-Opener-Policy: same-origin`

## Run it locally

Inside this project run:

```bash
$ yarn install
# or if you prefer npm:
$ npm install
```

### Start it

Now start the test server with vite:

```bash
$ yarn run dev
# or if you prefer npm:
$ npm run dev
```

and go to http://localhost:5173
13 changes: 13 additions & 0 deletions vite/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vite App</title>
</head>
<body>
<div id="app"></div>
<script type="module" src="/main.js"></script>
</body>
</html>
1 change: 1 addition & 0 deletions vite/javascript.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
37 changes: 37 additions & 0 deletions vite/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import "./style.css";
import javascriptLogo from "./javascript.svg";

import Dropzone from "dropzone";
import "dropzone/dist/dropzone.css";

document.querySelector("#app").innerHTML = `
<div>
<a href="https://vitejs.dev" target="_blank">
<img src="/vite.svg" class="logo" alt="Vite logo" />
</a>
<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript" target="_blank">
<img src="${javascriptLogo}" class="logo vanilla" alt="JavaScript logo" />
</a>
<h1>Hello Vite + Dropzone!</h1>
<small>Obviously the files dropped here will fail to upload because there is no server to accept them.</small>
<div class="card">
<form class="dropzone" id="my-form" action="/"></form>
</div>
<p class="read-the-docs">
Click on the Vite logo to learn more
</p>
<div class="card">
<h1>Debug output:</h1>
<pre id="output"></pre>
</div>
</div>
`;

const myDropzone = new Dropzone("#my-form");
const output = document.querySelector("#output");

myDropzone.on("addedfile", (file) => {
// Add an info line about the added file for each file.
output.innerHTML += `<div>File added: ${file.name}</div>`;
});

Loading