Skip to content

Commit

Permalink
add npm-crate-example
Browse files Browse the repository at this point in the history
  • Loading branch information
nshen committed Oct 14, 2021
1 parent 31171f0 commit 9463c5d
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 0 deletions.
14 changes: 14 additions & 0 deletions npm-crate-example/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>vite-plugin-wasm-pack example</title>
<script type="module" src="/src/index.ts"></script>
</head>
<body>
<h1>vite-plugin-wasm-pack example</h1>
<p>Can you see an alert window?</p>
</body>
</html>
17 changes: 17 additions & 0 deletions npm-crate-example/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"name": "npm-crate-example",
"version": "1.0.0",
"main": "index.js",
"license": "MIT",
"devDependencies": {
"vite": "^2.6.5",
"vite-plugin-wasm-pack": "^0.1.7"
},
"scripts": {
"dev": "vite",
"build": "vite build"
},
"dependencies": {
"test-npm-crate": "^0.3.0"
}
}
5 changes: 5 additions & 0 deletions npm-crate-example/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import init, { greet } from 'test-npm-crate';

init().then(() => {
greet();
});
11 changes: 11 additions & 0 deletions npm-crate-example/vite.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { defineConfig } from 'vite';
import wasmPack from 'vite-plugin-wasm-pack';

export default defineConfig({
build: {
minify: false
},
// use test-npm-crate from https://www.npmjs.com/package/test-npm-crate
// we have no local crate, so leave the first param an empty array
plugins: [wasmPack([], ['test-npm-crate'])]
});

0 comments on commit 9463c5d

Please sign in to comment.