2

I am using browserify + grunt to produce two separate JS outputs, a clientside and a serverside version of my app. eg.

gruntfile.js

browserify: {
    server: {
        files: { 'dist/server.js': ['src/serverside.js'], }
    },
    client: {
        files: { 'dist/client.js': ['src/clientside.js'], }
    }
}

Everything works nicely and I get 2 separate files.

Now I want my clientside app to use browserify-shim to reference some common libraries from a CDN.

eg.

"browserify-shim": {
    "libThing": "global:LibThing"
},
"browserify": {
    "transform": [
        "browserify-shim"
    ]
}

The issue is that this shims it for both the client and server versions, on the server this stuff doesn't exist in global.

I want to apply this shim just to the client (not the server)

I have tried

"browserify-shim": {
    "server": {
    }
    "client": {
        "libThing": "global:LibThing"
    }
},
"browserify": {
    "transform": [
        "browserify-shim"
    ]
}

but I cant seem to work out how to tell browserify to use a separate set of shims for each file.

undefined
  • 33,537
  • 22
  • 129
  • 198

0 Answers0