At the time of my original implementation of this, I am using Laravel 5.8, but as far as I know, this is still relevant and Larvel 7.x is out now. I'm trying to import a new javascript library into my Laravel 5.8 application using Mix. Specifically, the quill.js library.
Here are the steps I took to install quill and make it globally accessible in the application.
Install quill via npm
npm install quill --save-dev
Create a new file /resources/js/quill.js
In the quill.js file, I included the code that the quill documentation suggests: https://quilljs.com/guides/adding-quill-to-your-build-pipeline/
import Quill from 'quill/core';
import Toolbar from 'quill/modules/toolbar';
import Snow from 'quill/themes/snow';
import Bold from 'quill/formats/bold';
import Italic from 'quill/formats/italic';
import Header from 'quill/formats/header';
Quill.register({
'modules/toolbar': Toolbar,
'themes/snow': Snow,
'formats/bold': Bold,
'formats/italic': Italic,
'formats/header': Header
});
export default Quill;
In my app.js file, I included the quill.js file and assigned it to the global scope
require('./quill.js');
window.Quill = require('Quill');
Import the quill css in /resources/sass/app.scss
@import '~quill/dist/quill.core.css';
And for your theme
@import '~quill/dist/quill.snow.css';
Run npm run dev
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With