Skip to content

Instantly share code, notes, and snippets.

@rkaw92
Last active February 13, 2020 09:02
Show Gist options
  • Save rkaw92/26760708957b9f9deccf169857a59fae to your computer and use it in GitHub Desktop.
Save rkaw92/26760708957b9f9deccf169857a59fae to your computer and use it in GitHub Desktop.
Webpack config for bundling a dependency
<!DOCTYPE html>
<html>
<head>
<title>Library test</title>
</head>
<body>
<p id="datetime"></p>
<script src="dist/main.js"></script>
<script>
function displayTime() {
document.getElementById('datetime').textContent = myMoment().format();
}
setInterval(displayTime, 1000);
displayTime();
</script>
</body>
</html>
module.exports = {
mode: 'production',
entry: './node_modules/moment/moment.js',
output: {
libraryTarget: 'var',
library: 'myMoment'
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment