These are chat archives for AngularClass/angular2-webpack-starter

18th
Sep 2016
Mark Pritchett
@markpritchett
Sep 18 2016 18:44

Hi, I'm wanting to show the version number of my application.

I've added another property to the METADATA const in webpack.common.js, like so:

const METADATA = {
  title: 'Angular2 Webpack Starter by @gdi2290 from @AngularClass',
  baseUrl: '/',
  isDevServer: helpers.isWebpackDevServer(),
  version: require('../package.json').version
};

And I can output the value of this to src/index.html by doing:

<%= webpackConfig.metadata.version %>

However, this doesn't work in any other html template (the ones used by the angular components). I'm guessing it's because the HtmlWebpackPlugin in webpack.common.js is only looking at src/index.html:

new HtmlWebpackPlugin({
        template: 'src/index.html',
        chunksSortMode: 'dependency'
      }),

Ideally, I'd like to output the version of the application in a different template (maybe a footer component for example). I'm just not sure how to get it working though.