Within my Laravel project, I have developed a custom form validation class. However, after running npm run dev, I am unable to access this class.
Files:
small-form-validation.js
class SmallFormValidator {
errMsgs = {
required: 'This field is required!',
string: 'Not valid string.',
...
my app.js
require('./bootstrap');
require('./myvendor/small-form-validator');
Upon compilation, I discovered that the source code from the SmallFormValidator
class was present in the newly created app.js file within the public folder. It appears as though it compiled correctly.
In my blade template, I use the mixing helper to load the app.js file. However, within the JavaScript code inside the blade template, I encounter issues when trying to create an instance of SmallFormValidation
(var sfv = new SmallFormValidation()).
I suspect that these problems stem from either:
- My lack of familiarity with module exports and related concepts
- Potential scope-related issues
If anyone has insights on how to resolve this issue, I would greatly appreciate the assistance.