How to add React JS files in Codeigniter 4 Views while keeping js files in Views fold - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28) +--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forumdisplay.php?fid=30) +--- Thread: How to add React JS files in Codeigniter 4 Views while keeping js files in Views fold (/showthread.php?tid=76696) |
How to add React JS files in Codeigniter 4 Views while keeping js files in Views fold - myo - 06-10-2020 Also posted on stackoverflow: https://stackoverflow.com/questions/62307694/how-to-add-react-js-files-in-codeigniter-4-views-while-keeping-js-files-in-views I am trying to integrate react with Codeigniter 4. Its very easy to include js files by adding following line in my view file and keeping js files in public folder. Code: <script src="<?php echo base_url('react/react_file.js');?>"></script> We can also load .php files located within Views folder like following: Code: <?= view('include/any_php_file'); ?> But I want to keep js files in Views folder & want to load from there. How to include them from there in views? Any suggestions? RE: How to add React JS files in Codeigniter 4 Views while keeping js files in Views fold - jreklund - 06-10-2020 You can't. They need to be accessible from an url. If you still want to store them there, you need to write a PHP-loader. That will try to find that file inside your views folder and include it. |