okfn-brasil / perfil-politico-frontend

Front-end that consumes Perfil Político's API
https://perfilpolitico.serenata.ai
GNU General Public License v3.0
31 stars 25 forks source link

Adding Webpack #18

Closed gvarandas closed 5 years ago

gvarandas commented 5 years ago

Problem

The project was using Gulp as a project bundler and gulp-connect as a static server. The assets were not optimized and not compliant with the latest good practices (gzip, security headers, etc). Related issue: #12

Solution

Integrating Webpack and using ExpressJS to serve files.

Steps

Advantages

Performance

Bundles before optimization

bundles before optimization

Bundles after optimization

bundles after optimization
gvarandas commented 5 years ago

@cuducos just realized that this change might have impact on the deploy stage on netlify, since the gulp build task is no more. The deploy task probably must be updated to npm run build or just npm start (since that also triggers the build using npm hooks). Let me know if I can contribute with something else.

cuducos commented 5 years ago

Many thanks @gvarandas : )

As I'm not an JS expert, would you mind to clarify a detail? Is the idea to use Express on production? I think his unnecessary, as we aim at a static file. If that's the case, does it make sense to remove Express and propose a script that simply feed the build/ directory with the static/minified files?

Alternatively, if this does not make sense, this PR needs to update the README.md.

gvarandas commented 5 years ago

@cuducos you're totally correct. Just checked and realized that Netlify already provide a static hosting to files. In this case Express will be redundant (and I dont even think it would work). For local development we can use the webpack-dev-server tooling. I will update the PR, removing all Express references and changing the README.md accordingly.

Sorry for this. This is my first contact with Netlify. I'm totally used to Heroku. 😄

cuducos commented 5 years ago

Sorry for this. This is my first contact with Netlify. I'm totally used to Heroku.

No worries : )

gvarandas commented 5 years ago

Done! The README.md did not need any updates, since I've changed the npm scripts to reflect the current tasks (build and start). I've also updated the package.json to expose the Node and NPM versions under the engines property (this will help developers and deploy tools to guarantee that the required versions are up to date).