Skip to content

Instantly share code, notes, and snippets.

@BrandesEric
Created November 30, 2016 15:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BrandesEric/afa9cdb48acb5104d280ae639bd165d4 to your computer and use it in GitHub Desktop.
Save BrandesEric/afa9cdb48acb5104d280ae639bd165d4 to your computer and use it in GitHub Desktop.
Webpack Example
<html>
<head>
<script src="/dist/bundle.js">
</script>
</head>
</html>
// Make sure to set up the token and initial config somewhere before you load trackjs for the first time. This only needs to be done once.
window._trackJs = {
token: "my_token"
}
// variable name 'bob' chosen only to confirm exports loader is actually exporting
var bob = require('trackjs');
console.log(bob);
bob.track('hello');
{
"name": "webpack-example",
"version": "1.0.0",
"dependencies": {
"exports-loader": "^0.6.3",
"trackjs": "^2.5.3",
"webpack": "^1.13.3"
}
}
module.exports = {
entry: {
"bundle": "./main.js"
},
output: {
path: "./dist/",
filename: "[name].js"
},
module: {
loaders:[{
test: require.resolve("trackjs"),
loader: "exports?trackJs"
}]
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment