Unable to compile .wasm from npm package, <script> in index head blocked by CORS

Got tunnel vision and figured it out. Example repo here.

Magic webpack config:

vue.config.js

const CopyWebpackPlugin = require('copy-webpack-plugin');

module.exports = {
    configureWebpack: {
      output: {
          publicPath: "/"
        },
      plugins: [ 
          new CopyWebpackPlugin([ { from: 'node_modules/rhino3dm/rhino3dm.wasm', to: 'js/' } ]) 
        ],
    }
}

This appears to be a hacky way to force any emscripten generated wasm to hop over whatever webpack is trying to do with it (which is still unclear).

2 Likes