2

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?

1 Answer 1

1

You can't use ../ in an HTML reference - should be a web path not a file path - I would think that is the problem.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.