Add WASM bindings and web project structure

This commit is contained in:
Keavon Chambers
2021-03-27 02:26:54 -07:00
parent bca97cbeff
commit df39091107
13 changed files with 373 additions and 21 deletions
+3
View File
@@ -0,0 +1,3 @@
node_modules/
dist/
pkg/
+5
View File
@@ -0,0 +1,5 @@
const wasm = import("./pkg");
wasm
.then(wasm => wasm.greet())
.catch(console.error);
+24
View File
@@ -0,0 +1,24 @@
{
"name": "graphite-web-frontend",
"version": "0.1.0",
"description": "Graphite's web app frontend pathfinder. Planned to be replaced by a Rust native GUI framework in the future.",
"main": "main.js",
"scripts": {
"build": "webpack",
"start": "webpack serve"
},
"repository": {
"type": "git",
"url": "git+https://github.com/keavon/graphite.git"
},
"author": "Keavon Chambers <graphite@keavon.com>",
"license": "Apache-2.0",
"homepage": "https://www.graphite.design",
"devDependencies": {
"@wasm-tool/wasm-pack-plugin": "^1.3.3",
"html-webpack-plugin": "^5.1.0",
"webpack": "^5.21.2",
"webpack-cli": "^4.5.0",
"webpack-dev-server": "^3.11.2"
}
}
+23
View File
@@ -0,0 +1,23 @@
const path = require('path');
const HtmlWebpackPlugin = require("html-webpack-plugin");
const WasmPackPlugin = require("@wasm-tool/wasm-pack-plugin");
module.exports = {
entry: "./main.js",
output: {
path: path.resolve(__dirname, "dist"),
filename: "main.js",
},
plugins: [
new HtmlWebpackPlugin({ title: 'Graphite' }),
new WasmPackPlugin({
crateDirectory: path.resolve(__dirname, "..", "packages", "wasm-bindings"),
outDir: path.resolve(__dirname, "pkg"),
}),
],
mode: "development",
devtool: 'source-map',
experiments: {
syncWebAssembly: true,
},
};