JavaScript and alert popup not running in wordpress , even if gulpfile.js runs

Viewed 82

in functions.php I have following code

 function university_files()
{
  wp_enqueue_script('main-university-js', get_theme_file_uri('/js/scripts-bundled.js'), array('jquery'), '1.0', true);
}

add_action('wp_enqueue_scripts', 'university_files');

**and  in scripts.js i have code like this**

// 3rd party packages from NPM
import $ from 'jquery';
import slick from 'slick-carousel';

// Our modules / classes
import Search from './modules/Search';
import MyNotes from './modules/MyNotes';

// Instantiate a new object using our modules/classes
var search = new Search();
var mynotes = new MyNotes();

alert("this   is a js script");

**but whenever i try to reload page alert msg wont come**

**i have installed package json and the following is the gulpfile.js**

var gulp = require('gulp');

// Watch for file updates
gulp.task('watch', function () {
  gulp.watch('js/**/*.js').on('change', function (file) {
    //console.log(file);
    console.log(('JS changed' + ' (' + file.path + ')'));
  });
});

file structure and gulp watch running image

enter image description here

but when i try to run gulp watch it executes properly but after refresh the wordpress main page i wont receive alert mesaage which was written in scripts.js file(its under js folder along with bundledscripts.js)

enter image description here

0 Answers
Related