cds-snc / node-starter-app

Quick start application setup.... because you have to start somewhere.
MIT License
5 stars 3 forks source link

Default with webpack #109

Closed timarney closed 4 years ago

timarney commented 4 years ago

This adds webpack to the starter by default.

1) Allows our JS files to easily be minified, concatenated 2) Allows us to use "modern JS" and compile it back to target browsers 3) Opens up the opportunity to use React, Vue, Svelte etc....

Key thing - you don't need to know how to config Webpack to use this that's all managed a layer above (cds-snc/webpack-starter)

To use:

Add your entry to the Webpack config:

entry: {
      personal: './routes/personal/js/personal.js',
    },

Use the file(s) in your route

.get((req, res) => {
      const js = getClientJs(req, route.name)
      res.render(
        route.name,
        routeUtils.getViewData(req, { jsFiles: js ? [js] : false }),
      )
    })