diff --git a/template/package.json b/template/package.json index 26c4708..5073ece 100644 --- a/template/package.json +++ b/template/package.json @@ -4,15 +4,15 @@ "version": "0.1.0", "scripts": { "build": "rimraf dist pkg && webpack", - "start": "rimraf dist pkg && webpack-dev-server --open -d", + "start": "rimraf dist pkg && webpack-dev-server --mode=development", "test": "cargo test && wasm-pack test --headless" }, "devDependencies": { "@wasm-tool/wasm-pack-plugin": "^1.1.0", - "copy-webpack-plugin": "^5.0.3", - "webpack": "^4.42.0", - "webpack-cli": "^3.3.3", - "webpack-dev-server": "^3.7.1", - "rimraf": "^3.0.0" + "copy-webpack-plugin": "^13.0.0", + "webpack": "^5.99.8", + "webpack-cli": "^6.0.1", + "webpack-dev-server": "^5.2.1", + "rimraf": "^6.0.1" } } diff --git a/template/webpack.config.js b/template/webpack.config.js index d35da09..eb6026c 100644 --- a/template/webpack.config.js +++ b/template/webpack.config.js @@ -1,5 +1,5 @@ -const path = require("path"); -const CopyPlugin = require("copy-webpack-plugin"); +const path = require("node:path"); +const CopyWebpackPlugin = require("copy-webpack-plugin"); const WasmPackPlugin = require("@wasm-tool/wasm-pack-plugin"); const dist = path.resolve(__dirname, "dist"); @@ -7,22 +7,43 @@ const dist = path.resolve(__dirname, "dist"); module.exports = { mode: "production", entry: { - index: "./js/index.js" + index: "./js/index.js", }, output: { path: dist, - filename: "[name].js" + filename: "[name].js", }, devServer: { - contentBase: dist, + static: { + directory: dist, + }, + }, + performance: { + hints: "warning", + maxAssetSize: 500 * 1024, + maxEntrypointSize: 500 * 1024, + assetFilter: (assetFilename) => { + return !/\.wasm$/.test(assetFilename); + }, }, plugins: [ - new CopyPlugin([ - path.resolve(__dirname, "static") - ]), + new CopyWebpackPlugin({ + patterns: [path.resolve(__dirname, "static")], + }), new WasmPackPlugin({ crateDirectory: __dirname, }), - ] + ], + module: { + rules: [ + { + test: /\.wasm$/, + type: "webassembly/async", + }, + ], + }, + experiments: { + asyncWebAssembly: true, + }, };