Created
November 30, 2016 15:41
-
-
Save BrandesEric/afa9cdb48acb5104d280ae639bd165d4 to your computer and use it in GitHub Desktop.
Webpack Example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<script src="/dist/bundle.js"> | |
</script> | |
</head> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "webpack-example", | |
"version": "1.0.0", | |
"dependencies": { | |
"exports-loader": "^0.6.3", | |
"trackjs": "^2.5.3", | |
"webpack": "^1.13.3" | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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