Hello, I’m new to Sage and WordPress in general. I’m running a basic setup, out of the box. I’ve added console.log('ready..'); to my main.js in the normal sage install location, just for a simple yest, and yet I do not see any console logs.
Any ideas? This must be some simple thing that I’m not picking up on. Thanks for any help!
I’m using NPM for commands. I haven’t run build though, since I’m in dev I just run npm run start and webpack compiles. So, if I save a change in say, main.js it says “Compiling” … So, do I also need to run npm run build every time I make a .js file change?
I suspect that since you are adding the console.log statement to main.js (the entry) as opposed to the routes/common.js (a module), it’s not able to inject the updated via HMR. I could be horribly wrong though.
What happens when you run npm run build and just view the site in the browser?
Crazy enough, with npm run build I get the console logs. I think one thing is apparent though, I should put stuff I to common.js or maybe a .js file I make in autoload?
In Sage 9, we’re using the DOM router for scoping code per route. For (most) common code, you can put it within the init function of the default export in routes/common.js. The autoload directory is intended to be used by Sage 9 presets.