/* eslint-env node */
const { configure } = require('quasar/wrappers')

module.exports = configure(function () {
  return {
    boot: ['pinia'],

    css: ['app.scss', 'tech.scss'],

    extras: ['material-icons'],

    build: {
      target: {
        browser: ['es2019', 'edge88', 'firefox78', 'chrome87', 'safari13.1'],
        node: 'node20',
      },
      vueRouterMode: 'hash',
      extendViteConf (viteConf) {
        viteConf.base = process.env.DEPLOY_BASE || '/ops/'
      },
    },

    devServer: {
      open: false,
      host: '0.0.0.0',
      port: 9001,
      proxy: {
        '/ops/api': {
          target: 'https://erp.gigafibre.ca',
          changeOrigin: true,
          rewrite: (path) => path.replace(/^\/ops/, ''),
        },
        '/api': {
          target: 'https://erp.gigafibre.ca',
          changeOrigin: true,
        },
      },
    },

    framework: {
      config: {},
      plugins: ['Notify', 'Loading', 'LocalStorage', 'Dialog'],
    },

    animations: [],

    pwa: {
      workboxMode: 'generateSW',
      injectPwaMetaTags: true,
      swFilename: 'sw.js',
      manifestFilename: 'manifest.json',
      useCredentialForManifestTag: false,
      workboxOptions: {
        skipWaiting: true,
        clientsClaim: true,
        cleanupOutdatedCaches: true,
        navigateFallback: 'index.html',
        navigateFallbackDenylist: [/^\/api\//],
      },
      extendManifestJson (json) {
        json.name = 'Targo Ops'
        json.short_name = 'Ops'
        json.description = 'Targo Operations Platform'
        json.display = 'standalone'
        json.background_color = '#ffffff'
        json.theme_color = '#1e293b'
        json.start_url = '.'
      },
    },
  }
})
