podlove / podlove-publisher

Podlove Podcast Publisher for WordPress
https://wordpress.org/plugins/podlove-podcasting-plugin-for-wordpress/
MIT License
299 stars 84 forks source link

Improve webpack config #1205

Open alexander-heimbuch opened 3 years ago

alexander-heimbuch commented 3 years ago

The publisher uses laravel mix for webpack abstraction to build the javascript assets. This abstraction limits the abilities of independent applications.

Acceptance Criteria:

alexander-heimbuch commented 3 years ago

We might also need to migrate existing jQuery code to VueJS, would simplify the migration.

eteubert commented 3 years ago

Would love to use TailwindCSS and https://headlessui.dev (for vue) but that requires vue3 and I don't think I can or should squeeze that into the current laravel-mix setup. $prio++

Are you planning to build a webpack config by hand or something like vite / Snowpack / whatever?

alexander-heimbuch commented 3 years ago

Depends on the migration path for existing jQuery code. That might be tricky to bundle with vite. Worst case we will have our own webpack config.

eteubert commented 3 years ago

Had a quick look, there are ~2.000 lines of jQuery-style-JS. I don't think it's a realistic goal to rewrite all of this in one big swoop.

eteubert commented 3 years ago

First ~200 lines file done :) Some thoughts:

CSS Selector hiccups

Selecting by data attributes requires quotes around the values

--- el.querySelector("li a[data-id=" + id + "]")
+++ el.querySelector("li a[data-id='" + id + "']")

Use :first-child instead of :first

--- el.querySelector("li a:first")
+++ el.querySelector("li a:first-child")

Example fetch POST request:

fetch(ajaxurl, {
    method: 'POST',
    body: new URLSearchParams({action: 'podlove-action-name', id: template_id})
})
.then((response) => response.json())
.then((data) => {
    // handle json response
})

Example fetch GET request:

const params = new URLSearchParams({
    id: template_id,
    action: 'podlove-template-get'
});

fetch(ajaxurl + '?' + params.toString())
.then((response) => response.json())
.then((data) => {
  // handle json response
})