pressbooks / pressbooks-network-catalog

A Pressbooks plugin which provides an improved catalog for the Pressbooks Aldine theme
2 stars 1 forks source link

Make compatible with Vite 4 #181

Closed SteelWagstaff closed 1 year ago

SteelWagstaff commented 1 year ago

Something's broken with our build process. Instead of generating a js and css file and adding them to the head of the catalog page as scripts and styles, the CSS file is being declared as a javascript file. See: <script type="text/javascript" src="https://pressbooks.test/app/plugins/pressbooks-network-catalog//dist/assets/app-20ea0633.css?ver=6.1.1" id="pb-network-catalog/script-js"></script> Screenshot from 2023-03-14 15-24-04

Expected output is

See https://pressbooks.community/t/catalogue-problem-for-version-6-1-1/2301/30

SteelWagstaff commented 1 year ago

This broke when we upgraded to Vite 4, which bundles rollup.js 3.*). Here's the problem: https://rollupjs.org/command-line-interface/#getting-the-current-directory (found this when reading https://rollupjs.org/migration/). We use __dirname in several places: https://github.com/pressbooks/pressbooks-network-catalog/blob/5767b01be2fa9fe76df350c8ce29a9a92eb7c40c/vite.config.js#L19-L37.

Simplest fix for now is to revert to Vite 3 until someone smarter than me can come up with a fix.