Showing
9 changed files
with
162 additions
and
0 deletions
1 | +#!/usr/bin/env node | ||
2 | + | ||
3 | +const { spawn } = require("child_process"); | ||
4 | +const fs = require("fs"); | ||
5 | + | ||
6 | +let folderName = '.'; | ||
7 | + | ||
8 | +if (process.argv.length >= 3) { | ||
9 | + folderName = process.argv[2]; | ||
10 | + if (!fs.existsSync(folderName)) { | ||
11 | + fs.mkdirSync(folderName); | ||
12 | + } | ||
13 | +} | ||
14 | + | ||
15 | +const clone = spawn("git", ["clone", "https://github.com/rustwasm/create-wasm-app.git", folderName]); | ||
16 | + | ||
17 | +clone.on("close", code => { | ||
18 | + if (code !== 0) { | ||
19 | + console.error("cloning the template failed!") | ||
20 | + process.exit(code); | ||
21 | + } else { | ||
22 | + console.log("🦀 Rust + 🕸 Wasm = ❤"); | ||
23 | + } | ||
24 | +}); |
tutorial/wasm-game-of-life/www/.gitignore
0 → 100644
tutorial/wasm-game-of-life/www/README.md
0 → 100644
1 | +<div align="center"> | ||
2 | + | ||
3 | + <h1><code>create-wasm-app</code></h1> | ||
4 | + | ||
5 | + <strong>An <code>npm init</code> template for kick starting a project that uses NPM packages containing Rust-generated WebAssembly and bundles them with Webpack.</strong> | ||
6 | + | ||
7 | + <p> | ||
8 | + <a href="https://travis-ci.org/rustwasm/create-wasm-app"><img src="https://img.shields.io/travis/rustwasm/create-wasm-app.svg?style=flat-square" alt="Build Status" /></a> | ||
9 | + </p> | ||
10 | + | ||
11 | + <h3> | ||
12 | + <a href="#usage">Usage</a> | ||
13 | + <span> | </span> | ||
14 | + <a href="https://discordapp.com/channels/442252698964721669/443151097398296587">Chat</a> | ||
15 | + </h3> | ||
16 | + | ||
17 | + <sub>Built with 🦀🕸 by <a href="https://rustwasm.github.io/">The Rust and WebAssembly Working Group</a></sub> | ||
18 | +</div> | ||
19 | + | ||
20 | +## About | ||
21 | + | ||
22 | +This template is designed for depending on NPM packages that contain | ||
23 | +Rust-generated WebAssembly and using them to create a Website. | ||
24 | + | ||
25 | +* Want to create an NPM package with Rust and WebAssembly? [Check out | ||
26 | + `wasm-pack-template`.](https://github.com/rustwasm/wasm-pack-template) | ||
27 | +* Want to make a monorepo-style Website without publishing to NPM? Check out | ||
28 | + [`rust-webpack-template`](https://github.com/rustwasm/rust-webpack-template) | ||
29 | + and/or | ||
30 | + [`rust-parcel-template`](https://github.com/rustwasm/rust-parcel-template). | ||
31 | + | ||
32 | +## 🚴 Usage | ||
33 | + | ||
34 | +``` | ||
35 | +npm init wasm-app | ||
36 | +``` | ||
37 | + | ||
38 | +## 🔋 Batteries Included | ||
39 | + | ||
40 | +- `.gitignore`: ignores `node_modules` | ||
41 | +- `LICENSE-APACHE` and `LICENSE-MIT`: most Rust projects are licensed this way, so these are included for you | ||
42 | +- `README.md`: the file you are reading now! | ||
43 | +- `index.html`: a bare bones html document that includes the webpack bundle | ||
44 | +- `index.js`: example js file with a comment showing how to import and use a wasm pkg | ||
45 | +- `package.json` and `package-lock.json`: | ||
46 | + - pulls in devDependencies for using webpack: | ||
47 | + - [`webpack`](https://www.npmjs.com/package/webpack) | ||
48 | + - [`webpack-cli`](https://www.npmjs.com/package/webpack-cli) | ||
49 | + - [`webpack-dev-server`](https://www.npmjs.com/package/webpack-dev-server) | ||
50 | + - defines a `start` script to run `webpack-dev-server` | ||
51 | +- `webpack.config.js`: configuration file for bundling your js with webpack | ||
52 | + | ||
53 | +## License | ||
54 | + | ||
55 | +Licensed under either of | ||
56 | + | ||
57 | +* Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0) | ||
58 | +* MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT) | ||
59 | + | ||
60 | +at your option. | ||
61 | + | ||
62 | +### Contribution | ||
63 | + | ||
64 | +Unless you explicitly state otherwise, any contribution intentionally | ||
65 | +submitted for inclusion in the work by you, as defined in the Apache-2.0 | ||
66 | +license, shall be dual licensed as above, without any additional terms or | ||
67 | +conditions. |
tutorial/wasm-game-of-life/www/bootstrap.js
0 → 100644
tutorial/wasm-game-of-life/www/index.html
0 → 100644
1 | +<!DOCTYPE html> | ||
2 | +<html> | ||
3 | + <head> | ||
4 | + <meta charset="utf-8"> | ||
5 | + <title>Hello wasm-pack!</title> | ||
6 | + </head> | ||
7 | + <body> | ||
8 | + <noscript>This page contains webassembly and javascript content, please enable javascript in your browser.</noscript> | ||
9 | + <script src="./bootstrap.js"></script> | ||
10 | + </body> | ||
11 | +</html> |
tutorial/wasm-game-of-life/www/index.js
0 → 100644
This diff could not be displayed because it is too large.
tutorial/wasm-game-of-life/www/package.json
0 → 100644
1 | +{ | ||
2 | + "name": "create-wasm-app", | ||
3 | + "version": "0.1.0", | ||
4 | + "description": "create an app to consume rust-generated wasm packages", | ||
5 | + "main": "index.js", | ||
6 | + "bin": { | ||
7 | + "create-wasm-app": ".bin/create-wasm-app.js" | ||
8 | + }, | ||
9 | + "scripts": { | ||
10 | + "build": "webpack --config webpack.config.js", | ||
11 | + "start": "webpack-dev-server" | ||
12 | + }, | ||
13 | + "repository": { | ||
14 | + "type": "git", | ||
15 | + "url": "git+https://github.com/rustwasm/create-wasm-app.git" | ||
16 | + }, | ||
17 | + "keywords": [ | ||
18 | + "webassembly", | ||
19 | + "wasm", | ||
20 | + "rust", | ||
21 | + "webpack" | ||
22 | + ], | ||
23 | + "author": "Ashley Williams <ashley666ashley@gmail.com>", | ||
24 | + "license": "(MIT OR Apache-2.0)", | ||
25 | + "bugs": { | ||
26 | + "url": "https://github.com/rustwasm/create-wasm-app/issues" | ||
27 | + }, | ||
28 | + "homepage": "https://github.com/rustwasm/create-wasm-app#readme", | ||
29 | + "devDependencies": { | ||
30 | + "hello-wasm-pack": "^0.1.0", | ||
31 | + "webpack": "^4.29.3", | ||
32 | + "webpack-cli": "^3.1.0", | ||
33 | + "webpack-dev-server": "^3.1.5", | ||
34 | + "copy-webpack-plugin": "^5.0.0" | ||
35 | + } | ||
36 | +} |
1 | +const CopyWebpackPlugin = require("copy-webpack-plugin"); | ||
2 | +const path = require('path'); | ||
3 | + | ||
4 | +module.exports = { | ||
5 | + entry: "./bootstrap.js", | ||
6 | + output: { | ||
7 | + path: path.resolve(__dirname, "dist"), | ||
8 | + filename: "bootstrap.js", | ||
9 | + }, | ||
10 | + mode: "development", | ||
11 | + plugins: [ | ||
12 | + new CopyWebpackPlugin(['index.html']) | ||
13 | + ], | ||
14 | +}; |
Please
register
or
login
to post a comment