Welcome Guest, Not a member yet? Register   Sign In
How to include script located in node_modules folder using codeigniter 4?
#1

I need to install this plugin on my application, so I followed the instruction and executed:

    
PHP Code:
npm install --save @ckeditor/ckeditor5-upload 


Usually, to load a plugin I create a file inside the `load` directory which contains the plugin name, in particular:

   
PHP Code:
Views
        load
            ckeditor
.php 

which contains this:

   
PHP Code:
<!-- Push section js -->
    <?= $this->section('js'?>
    <script src="https://cdn.ckeditor.com/ckeditor5/27.1.0/classic/ckeditor.js"></script>
    <script src="https://cdn.ckeditor.com/ckeditor5/27.1.0/classic/translations/it.js"></script>
    <?= $this->endSection() ?>

so to include in a specific section of my app, I simply do:

   
PHP Code:
<?= $this->include('App\Views\Backend\load\ckeditor'?>


and this will inject the plugin into my app, but how can I do this with local dependencies installed via npm?
Reply
#2

If you look on that page the last code sample is for 2 editors but it is showing all the html code.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#3

(05-20-2021, 02:41 AM)InsiteFX Wrote: If you look on that page the last code sample is for 2 editors but it is showing all the html code.

But I cannot use import since is not a module, am I missing something??
Reply
#4

You will need to use a build process to build/copy files you need from node_modules into public/assets/ (or whatever your assets folder is called).

E.g. Webpack, Laravel Mix, Parcel, Rollup, Gulp. There are so many.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB