Full disclosure: My expertise lies mainly in backend development, and I don't have extensive knowledge in front-end technologies.
I am in the process of creating a Golang web application that does not use a single page application (SPA) architecture. Instead, it generates HTML that is then delivered to the user. As I strive to improve the management and tracking of my JavaScript and CSS dependencies, I am considering transitioning to utilizing NPM with a package.json
file rather than manually downloading and integrating CSS and JavaScript libraries. These libraries typically include jquery, bootstrap, and fontawesome. Additionally, I currently have one JavaScript file per page for interactive elements.
Here is an example of how my project is structured:
+ js
lib.js -> jquery, bootstrap, fontawesome
- home -> specific JS
- account -> specific JS
...
+ css
theme.css
custom.css
However, I have not found a straightforward solution that allows me to simply run npm install
and generate a minified vendor.js
file with all the installed packages. I have explored using webpack (specifically go-webpack), but found it overly complex with terms like tree shaking, bundling, and shimming. Furthermore, webpack requires setting up a development server for local asset serving, implementing special chunk handling, and referencing global libraries in every JavaScript file to prevent them from being removed during optimization.
Is there a more straightforward way to streamline the process from a package.json
file to a consolidated, minified asset bundle?