new command javascript generate
Problem:
So far, we've built JS and CSS files independently of their associated HTML files. For example, the HTML references src=main.mjs
, and the file main.mjs
is generated somewhere without a direct connection to the HTML file.
Proposed Solution:
Instead of building all JS and CSS files indiscriminately, we link the build process directly to the HTML file. This way, only the files referenced in the HTML file are built.
Example of the new syntax:
<script
data-bob-source="source/main.mjs"
data-bob-target="es6"
data-bob-script-dist="scripts/main.mjs"
data-bob-style-dist="styles/main.css"
src="/scripts/main.mjs"
type="module">
</script>
Additional Benefit:
This approach even allows us to build language-specific JS files, significantly improving flexibility and efficiency.