Use vite instead of webpack

This commit is contained in:
Fabian Schmidt 2025-02-24 13:27:49 +01:00
parent 922a7d3160
commit 451263fcb4
4 changed files with 760 additions and 2252 deletions

View File

@ -7,8 +7,9 @@
"create-wasm-app": ".bin/create-wasm-app.js"
},
"scripts": {
"build": "webpack --config webpack.config.js",
"start": "webpack-dev-server"
"dev": "vite",
"build": "vite build",
"start": "vite preview"
},
"repository": {
"type": "git",
@ -30,9 +31,9 @@
"wasm-game-of-life": "file:../pkg"
},
"devDependencies": {
"copy-webpack-plugin": "^12.0.2",
"webpack": "^5.98.0",
"webpack-cli": "^6.0.1",
"webpack-dev-server": "^5.2.0"
"vite": "^6.1.1",
"vite-plugin-static-copy": "^2.2.0",
"vite-plugin-top-level-await": "^1.5.0",
"vite-plugin-wasm": "^3.4.1"
}
}

File diff suppressed because it is too large Load Diff

31
www/vite.config.mjs Normal file
View File

@ -0,0 +1,31 @@
import { defineConfig } from 'vite';
import { viteStaticCopy } from 'vite-plugin-static-copy';
import wasm from 'vite-plugin-wasm';
import topLevelAwait from 'vite-plugin-top-level-await';
export default defineConfig({
build: {
target: 'esnext',
outDir: 'dist',
rollupOptions: {
input: './bootstrap.js',
output: {
entryFileNames: 'bootstrap.js',
},
},
},
plugins: [
viteStaticCopy({
targets: [
{
src: 'index.html',
dest: '',
},
],
}),
wasm(),
topLevelAwait()
],
mode: 'development',
});

View File

@ -1,19 +0,0 @@
const CopyWebpackPlugin = require("copy-webpack-plugin");
const path = require('path');
module.exports = {
entry: "./bootstrap.js",
output: {
path: path.resolve(__dirname, "dist"),
filename: "bootstrap.js",
},
mode: "development",
plugins: [
new CopyWebpackPlugin({
patterns: ['index.html']
})
],
experiments: {
asyncWebAssembly: true
}
};