I'm working on a project with Node.js and Express.js.
I need to use Quill and I'm trying to include it from my node_modules folder. (Can't from the CDN because of Content Security Policy issue with nginx).
So, what I've done:
//index.js
app.use(
express.static(path.join(__dirname, "..", "..", "node_modules", "quill"))
);
and
//page.ejs
<script type="module" src="/quill.js"></script>
So far, it works, as it includes node_modules/quill/quill.js successfully in the DOM but, it's showing 404 errors for all the other files within node_modules/quill folder which are being imported from node_modules/quill/quill.js file.
For example, these imports:
//node_modules/quill/quill.js
import Quill from './core';
import { AlignClass, AlignStyle } from './formats/align';
import { DirectionAttribute, DirectionClass, DirectionStyle } from './formats/direction';
import { IndentClass as Indent } from './formats/indent';
import Blockquote from './formats/blockquote';
import Header from './formats/header';
import List, { ListItem } from './formats/list';
import { BackgroundClass, BackgroundStyle } from './formats/background';
import { ColorClass, ColorStyle } from './formats/color';
import { FontClass, FontStyle } from './formats/font';
cause these errors in the browser console:
Failed to load resource: the server responded with a status of 404 (Not Found) /formats/align:1
Failed to load resource: the server responded with a status of 404 (Not Found) /formats/direction:1
Failed to load resource: the server responded with a status of 404 (Not Found) /formats/indent:1
Failed to load resource: the server responded with a status of 404 (Not Found) /formats/blockquote:1
Failed to load resource: the server responded with a status of 404 (Not Found) /formats/background:1
Failed to load resource: the server responded with a status of 404 (Not Found) /formats/list:1
Failed to load resource: the server responded with a status of 404 (Not Found) /formats/color:1
...
..
Failed to load resource: the server responded with a status of 404 /formats/header:1
What am I doing wrong?
I'm open to any changes/suggestions on how to include this library (including from their CDN).
Thanks