How to package feathersjs+primus generated client js?

182 Views Asked by At

I am using feathersjs as restful API and primusjs as websocket connection. Below is the code I am using to generate primus.js file:

app.configure(primus({
    transformer: 'websockets',
    timeout: false
  }, (primus) => {
    primus.library();
    primus.save(path.join(__dirname, '../public/dist/primus.js'));
  }))

In order to let my client to use the generated primus.js file. I have to serve this file from my server. From the client side, it can use it like below:

<script src='http://xxxxxx/public/dist/primus.js'>

But my client is using webpack to package every dependencies into a few big js files. How can I package primus.js file in client if it is an auto generated file?

1

There are 1 best solutions below

5
Daff On

I don't believe you can out of the box but it looks like there is a primus-webpack-plugin:

This plugin allows you to pass in your Primus options and then adds the client library to your Webpack build assets.