const webpack = require('webpack');
const fs = require('fs');
const packageJson = fs.readFileSync('./package.json');
const version = JSON.parse(packageJson).version || 0;

module.exports = {
  publicPath: '/geocontrib/',
  devServer: {
    proxy: {
      '^/api': {
        target: 'https://geocontrib.dev.neogeo.fr/api',
        ws: true,
        changeOrigin: true
      }
    }
  },
  pwa: {
    workboxPluginMode: 'InjectManifest',
    workboxOptions: {
      swSrc: 'src/service-worker.js',
      exclude: [
        /\.map$/, 
        /config\/config.*\.json$/,
        /manifest\.json$/ 
      ],
    },
    iconPaths: {
      faviconSVG: null,
      favicon32: null,
      favicon16: null,
      appleTouchIcon: null,
      maskIcon: null,
      msTileImage: null,
    },
    themeColor: '#1da025'
  },
  configureWebpack: {
    devtool: 'source-map',
    plugins: [
      new webpack.DefinePlugin({
        'process.env': {
          PACKAGE_VERSION: '"' + version + '"'
        }
      })
    ]
  },
  transpileDependencies: [
    // Add dependencies that use modern JavaScript syntax, based on encountered errors
    'ol',
    'color-rgba',
    'color-parse'
  ]
};