因此,我尝试使用Webpack捆绑我的Wasm模块。一切都能很好地编译,但是每当我在服务器上对其进行测试时,它都会在http://127.0.0.1:8080/0.bundle.js
下查找捆绑文件。我没有使用webpack开发服务器,我宁愿不更改文件结构。
我的文件结构如下:
├── assets
├── index.html
├── index.js
├── serialization
│ ├── pkg
│ │ ├── dist
│ │ │ ├── 0.bundle.js
│ │ │ ├── 3f139ff5ad432befd963.module.wasm
│ │ │ └── bundle.js
pkg
文件夹中包含我要捆绑的文件的位置。
我当前的Webpack配置如下:
const path = require('path');
const webpack = require('webpack');
module.exports = {
entry: '../../index.js',
output: {
path: path.resolve(__dirname, 'dist'),
publicPath: path.resolve('./serialization/pkg/dist/'),
filename: 'bundle.js',
},
};
为什么Webpack仍然直接在localhost下而不是在public path子目录下查找文件?
我要实现的是将我的模块加载到http://127.0.0.1:8080/serialization/pkg/dist/0.bundle.js下。现在无论何时加载模块,都不会找到404,因为它是直接在我的根目录(http://127.0.0.1:8080/0.bundle.js)中寻找它的。