const { defineConfig } = require('@vue/cli-service')
const NodePolyfillPlugin = require('node-polyfill-webpack-plugin')

module.exports = defineConfig({
  configureWebpack: {
    plugins: [new NodePolyfillPlugin()]
  },
  transpileDependencies: true,
  lintOnSave: false,
  devServer: {
    historyApiFallback: true,
    allowedHosts: 'all',
    proxy: {
      '/api': {
        target: 'http://testofficial.jhcs888.com/api/',
        changeOrigin: true,
        pathRewrite: {
          '^/api': ''
        }
      },
      '/adminApi': {
        target: 'http://testofficial.jhcs888.com/adminApi/',
        changeOrigin: true,
        pathRewrite: {
          '^/adminApi': ''
        }
      }
    }
  },
  css: {
    loaderOptions: {
      sass: {
        sassOptions: {
          outputStyle: 'expanded'
        },
        prependData: '@import "~@/variables.sass"'
      },
      scss: {},
      postcss: {
        postcssOptions: {
          plugins: [
            require('postcss-plugin-px2rem')({
              rootValue: 144,
              minPixelValue: 5,
              selectorBlackList: ['mobile-h-s']
            })
          ]
        }
      }
    }
  }
})
