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

process.env.VUE_APP_VERSION = require('./package.json').version

const dayjs = require('dayjs')
const time = dayjs().format('YYYY-M-D HH:mm:ss')
process.env.VUE_APP_UPDATE_TIME = time

module.exports = defineConfig({
  publicPath: process.env.PUBLIC_PATH,
  productionSourceMap: process.env.VUE_APP_CLI_MODE === 'prod' ? false : true,
  // transpileDependencies: true, // 默认false，表示babel-loader 会忽略所有 node_modules 中的文件
  configureWebpack: {
    module: {
      rules: [
        // {
        //   test: /\.cur$/,
        //   use: {
        //     loader: 'file-loader'
        //   }
        // }
      ]
    },
    plugins: [
      new webpack.ProvidePlugin({
        utils: ['/src/utils.js', 'default'],
        store: ['/src/store/index.js', 'default'],
        api: ['/src/api.js', 'default'],
        config: ['/src/config.js', 'default'],
        mapState: ['vuex', 'mapState'],
        mapGetters: ['vuex', 'mapGetters'],
        mapMutations: ['vuex', 'mapMutations'],
        useSizeAdapt: ['/src/useFunctions/useSizeAdapt.js', 'default'],
      }),
    ],
  },
})
