Open zhaoyi0113 opened 7 years ago
The UMD output for primus client doesn't work well with client-side bundling like browersify and webpack, the purpose of this module is to get the client script built and added to assets to include in your HTML doc you send to client. Primus
is then available globally as window.Primus
. If you want to require/import primus you will have to alias the global Primus as primus in your build config
Is there an example for that? I tried below method but doesn't work.
new webpack.ProvidePlugin({
Primus: 'primus-client',
}),
once you add the provide plugin, how do you require primus in your app?
I just do import Primus from 'primes-client'
. Is it correct way to do?
I setup
primus-webpack-plugin
in webpack configuration file as below.In the js code, I import
Primus
and use it to send event to server as below:after doing this, I got below exception from the last line of above code:
It works fine if I serve the
primus client
from a static server. I only got this error when I use this webpack plugin.