Open marlti7 opened 8 years ago
https://github.com/Micjoyce/wechat-mina-ddp-example
There is another new and updated repo might help you.
webpack的配置文件 libraryTarget:'commonjs2' 如果不设置这个,将不会导出任何函数。
entry: './src/asteroid.js',
output: {
path: path.resolve(__dirname, 'dist'),
filename: 'asteroid.bundle.js',
libraryTarget:'commonjs2'
},
devtool: 'source-map',
mode: 'development',
};
另外asteroid还会有一个Websocket初始化的错误,解决方法是使用weapp.socket.io, 将SocketConstructor 设成 socketio
const socketio = require("../webpacknpm/weapp.socket.io/dist/weapp.socket.io.js");
const asteroid = require("../webpacknpm/asteroid/dist/asteroid.bundle.js");
function initAsteroid(endPoint){
const Asteroid = asteroid.createClass();
// Connect to a Meteor backend
const asteroidInst = new Asteroid({
endpoint: endPoint,
SocketConstructor: socketio
});
return asteroidInst;
}
module.exports = {
initAsteroid
}
引入路径没有问题