Skip to content

Instantly share code, notes, and snippets.

@debabratakarfa
Created April 26, 2019 13:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save debabratakarfa/2c54b2db6fd20db0269ba65b93de5f18 to your computer and use it in GitHub Desktop.
Save debabratakarfa/2c54b2db6fd20db0269ba65b93de5f18 to your computer and use it in GitHub Desktop.
admin_enqueue_scripts file not working
// import external dependencies
import 'jquery';
// Import everything from autoload
import './autoload/**/*'
// import local dependencies
import Router from './util/Router';
import adminCommon from './routes/adminCommon';
/** Populate Router instance with DOM routes */
const routes = new Router({
// All pages
adminCommon,
});
// Load Events
jQuery(document).ready(() => routes.loadEvents());
export default {
init() {
console.log('Admin Load');
// JavaScript to be fired on all pages
},
finalize() {
// JavaScript to be fired on all pages, after page specific JS is fired
},
};
{
"entry": {
"main": [
"./scripts/main.js",
"./styles/main.scss"
],
"admin": [
"./scripts/admin.js",
"./styles/admin.scss"
],
"customizer": [
"./scripts/customizer.js"
]
},
"publicPath": "/wp-content/themes/sage-local",
"devUrl": "http://local.wordpress.test",
"proxyUrl": "http://localhost:3000",
"cacheBusting": "[name]_[hash:8]",
"watch": [
"app/**/*.php",
"config/**/*.php",
"resources/views/**/*.php"
]
}
/**
* Admin assets load
*/
add_action( 'admin_enqueue_scripts', function() {
wp_enqueue_style('sage/admin.css', asset_path('styles/admin.css'), false, null);
wp_enqueue_script('sage/admin.js', asset_path('scripts/admin.js'), ['jquery'], null, true);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment