MetaCell / nwb-explorer

NWB Explorer is a web application to visualise and analyse the content of NWB:N 2 files
Other
23 stars 16 forks source link

Implement dynamic version injection #206

Open filippomc opened 3 years ago

filippomc commented 3 years ago

Pure frontend strategy using env variables

Inside the Docker image:

RUN VERSION=$(grep version setup.py | sed 's/^.*version="//g' | sed 's/\",//g') &&\ 
    npm run build --env.VERSION=$VERSION --env.COMMIT=$COMMIT

Inside the webpack:

module.exports = function (env){
  if (env === undefined) {
    env = {}
  }
  if (!env.COMMIT) {
    env.COMMIT = 'x.x.x'
  }
  if (!env.VERSION) {
    env.VERSION = PACKAGE.version
  }
...

Then use the following to get version

const PRESENT_COMMIT = process.env.COMMIT;
const PRESENT_VERSION = process.env.VERSION;