javascript - System.js won't import vendors on wordpress -
i'm trying recreate angular2 quickstart tutorial on wordpress i'm having issue systemjs imports. trying import angular2 results in error:
get http://localhost/wp-content/themes/ng2-wordpress/angular2/core 404 (not found)
i don't understand why looking physical path, , not systemjs module.
this systemjs script:
app/system-start.js
system.config({ baseurl: baseurl, packages: { app: { main: 'main', format: 'register', defaultextension: 'js' } } }); system.import('app') .then(null, console.error.bind(console)); app/main.ts (it's compiled of course):
import {bootstrap} 'angular2/platform/browser' import {appcomponent} './app.component' bootstrap(appcomponent); i'm putting everyhing html header this:
functions.php
function enqueue_script() { function register_vendor_script($script, $path) { wp_register_script($script, get_stylesheet_directory_uri().'/node_modules/'.$path); } register_vendor_script('es6-shim', 'es6-shim/es6-shim.min.js'); register_vendor_script('system-polyfills', 'systemjs/dist/system-polyfills.js'); register_vendor_script('angular2-polyfills', 'angular2/bundles/angular2-polyfills.js'); register_vendor_script('system', 'systemjs/dist/system.src.js'); register_vendor_script('rx', 'rxjs/bundles/rx.js'); register_vendor_script('angular2', 'angular2/bundles/angular2.dev.js'); wp_enqueue_script('system-start', get_stylesheet_directory_uri().'/app/system-start.js', array('es6-shim', 'system-polyfills', 'angular2-polyfills', 'system', 'rx', 'angular2') ); wp_localize_script( 'system-start', 'baseurl', trailingslashit(get_template_directory_uri()) ); } add_action('wp_enqueue_scripts', 'enqueue_script');
Comments
Post a Comment