0

I have a Rust, Web assembly wasm app I need to deploy to an apache server. When upload the build, it doesn't run the software, it just shows a list of the files.

The build files look like this:

build
  -0.bootstrap.js
  -bootstap.js
  -gfdgjkljlkjjiojohio.module.wasm

my webpack config looks like

const path = require('path');

module.exports = {
  entry: "./bootstrap.js",
  output: {
    path: path.resolve(__dirname, "dist"),
    filename: "bootstrap.js",
  },
  mode: "development",
  devServer: {
    //host: "0.0.0.0",
    port: 8080,
  }
};

Where boostrap.js imports the main index.js file

// A dependency graph that contains any wasm must all be imported
// asynchronously. This `bootstrap.js` file does the single async import, so
// that no one else needs to worry about it again.
import("./index.js")
  .catch(e => console.error("Error importing `index.js`:", e));

But when I deploy to my apache server, to my domain, I don't get the software running.

Why isn't it running?

Shingai Munyuki
  • 551
  • 1
  • 11
  • 25

1 Answers1

0

I had to use HtmlWebpackPlugin and change my webpack config to this

module.exports = {
  entry: './bootstrap.js',
  output: {
    filename: 'main.js',
    path: path.resolve(__dirname, 'dist')
  },
  plugins: [
    new CleanWebpackPlugin(),
    new HtmlWebpackPlugin({
      filename: 'index.html',
      inject: true,
      template: path.resolve(__dirname, 'index.html'),
    }),
  ]
}
Shingai Munyuki
  • 551
  • 1
  • 11
  • 25