1- const path = require ( 'path' ) ;
2- const HtmlWebpackPlugin = require ( 'html-webpack-plugin' ) ;
3- const webpack = require ( 'webpack' ) ;
1+ const HtmlWebpackPlugin = require ( "html-webpack-plugin" ) ;
42const WasmPackPlugin = require ( "@wasm-tool/wasm-pack-plugin" ) ;
53
64module . exports = {
7- entry : './index.js' ,
8- output : {
9- path : path . resolve ( __dirname , 'dist' ) ,
10- filename : 'bundle.js' , // changed from index.js to avoid conflicts
11- } ,
12- plugins : [
13- new HtmlWebpackPlugin ( {
14- template : 'index.html'
15- } ) ,
16- new WasmPackPlugin ( {
17- crateDirectory : path . resolve ( __dirname , "." )
18- } ) ,
5+ entry : "./index.js" , // Change this to your JS entry point if different
6+ output : {
7+ path : __dirname + "/dist" ,
8+ filename : "bundle.js" ,
9+ } ,
10+ mode : "development" , // Or "production"
11+ experiments : {
12+ asyncWebAssembly : true ,
13+ } ,
14+ module : {
15+ rules : [
16+ {
17+ test : / \. w a s m $ / ,
18+ type : "webassembly/async" ,
19+ } ,
1920 ] ,
20- mode : process . env . NODE_ENV || 'development' ,
21- experiments : {
22- asyncWebAssembly : true
23- } ,
24- module : {
25- rules : [
26- {
27- test : / \. w a s m $ / ,
28- type : 'webassembly/async'
29- }
30- ]
31- } ,
32- resolve : {
33- extensions : [ '.js' , '.wasm' ]
34- }
21+ } ,
22+ plugins : [
23+ new HtmlWebpackPlugin ( {
24+ template : "./index.html" , // Change this if your HTML entry is elsewhere
25+ } ) ,
26+ new WasmPackPlugin ( {
27+ crateDirectory : __dirname ,
28+ extraArgs : "--target bundler" ,
29+ } ) ,
30+ ] ,
31+ resolve : {
32+ extensions : [ ".js" , ".wasm" ] ,
33+ } ,
34+ devServer : {
35+ static : "./dist" ,
36+ hot : true ,
37+ } ,
3538} ;
0 commit comments