🗂
「RustとWebAssemblyによるゲーム開発」の長い音楽の再生を行ったときのコンパイルエラーに対処したメモ
概要
前回から続けてRustとWebAssemblyによるゲーム開発を写経していて7章で本で触れられていないエラーがでたのでメモ。
環境
- webpack: 5.93.0
- webpack-dev-server: 5.0.4
発生したエラー
WARNING
asset size limit: The following asset(s) exceed the recommended size limit (244 KiB).
This can impact web performance.
Assets: 
  background_song.mp3 (2.38 MiB)
解決法
調べてみたらWebpackの設定によるものだった。
デフォルトより大きくして解決。
webpack.config.js
const path = require("path");
const CopyPlugin = require("copy-webpack-plugin");
const WasmPackPlugin = require("@wasm-tool/wasm-pack-plugin");
const dist = path.resolve(__dirname, "dist");
module.exports = {
  mode: "production",
  entry: {
    index: "./js/index.js"
  },
  output: {
    path: dist,
    filename: "[name].js"
  },
  devServer: {
    static: { directory: dist }
  },
  experiments: {
       asyncWebAssembly: true,
  },
  plugins: [
    new CopyPlugin({patterns:[ path.resolve(__dirname, "static") ]}),
    new WasmPackPlugin({
      crateDirectory: __dirname,
    }),
  ],
+  performance: {
+    maxAssetSize: 5000000,
+  }
};



Discussion