angular-intercom
angular-intercom copied to clipboard
Not works when used with webpack
I create the sample repo https://github.com/Alex12321/test-intercom In this case I need to run intercom after page loads. But nothing happens.
You can see code what I used at this file: https://github.com/Alex12321/test-intercom/blob/master/client/app/app.js
To run:
npm install
gulp serve
According to my tests, it seems that the Intercom script is not even loaded from the CDN. Will continue to investigate.
(Correction: It is, but the ping endpoint isn't being hit)
The issue is that webpack allows using AMD, which is the first if
case. You need to disable AMD in webpack:
Install imports loader:
npm install imports-loader
On your require statement:
require('imports?define=>false!angular-intercom')
Complementing @derekstavis answer, this did the trick:
import 'imports?this=>window&exports=>false&define=>false!angular-intercom'
This fools angular-intercom's module startup tests ("exports=>false&define=>false") and works around webpack's scoping ("this=>window")