Reputation: 1071
I'm building small js es6 library.
class Library {
get(key) {
console.log("Get")
}
set(key, value, options) {
console.log("Set")
}
delete(key) {
console.log("Delete")
}
}
export default Library
I'm using laravel-mix to compile code.
let mix = require('laravel-mix')
mix.js('src/index.js', 'dist')
Then I import compiled script in HTML:
<html>
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
<h1>Title</h1>
<script src="../dist/index.js"></script>
<script>
var lib = new Library();
</script>
</body>
</html>
But I get js error: Uncaught ReferenceError: Library is not defined
What am I doing wrong?
Upvotes: 2
Views: 242
Reputation: 1156
You can't use ../ in an HTML reference - should be a web path not a file path - I would think that is the problem.
Upvotes: 1