javascript - Adding react app to an existing wordpress website

I have built a react app and I want to add it to my existing wordpress website. So basically when you visit mydomainrea

I have built a react app and I want to add it to my existing wordpress website. So basically when you visit mydomain/reactapp you should see the app. But for now I am getting a white page and in my console there is: 05123b.css 404 (Not Found)

Do i have to change something in my htaccess? Thanks

I have built a react app and I want to add it to my existing wordpress website. So basically when you visit mydomain/reactapp you should see the app. But for now I am getting a white page and in my console there is: https://www.mydomain.co.uk/static/css/main05123b.css 404 (Not Found)

Do i have to change something in my htaccess? Thanks

Share Improve this question edited May 12, 2018 at 17:09 Nathan Johnson 6,5286 gold badges30 silver badges49 bronze badges asked May 12, 2018 at 17:06 Wushu06 Wushu06 1
Add a comment  | 

2 Answers 2

Reset to default 0

You need to include scripts and styles properly as it has been done here https://github/radekzz/wordpress-react-in-theme

    add_action( 'wp_enqueue_scripts', 'enqueue_my_react_app' ); 
function enqueue_my_react_app(){ 
    foreach( glob( get_template_directory(). '/myReactApp/build/static/js/*.js' ) as $file ) {      
// $file contains the name and extension of the file        
$filename = substr($file, strrpos($file, '/') + 1);         wp_enqueue_script( $filename, get_template_directory_uri().'/myReactApp/build/static/js/'.$filename); 
}   foreach( glob( get_template_directory(). '/myReactApp/build/static/css/*.css' ) as $file ) {        
// $file contains the name and extension of the file        
$filename = substr($file, strrpos($file, '/') + 1);         wp_enqueue_style( $filename, get_template_directory_uri().'/myReactApp/build/static/css/'.$filename);   
}
 }

I just needed to change the publicPath inside my webpack.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745266739a4619503.html

相关推荐

  • javascript - Adding react app to an existing wordpress website

    I have built a react app and I want to add it to my existing wordpress website. So basically when you visit mydomainrea

    5小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信