text: // eslint-disable-next-line @typescript-eslint/no-var-requires
  const path = require('path')
  
  // If your port is set to 80,
  // use administrator privileges to execute the command line.
  // For example, on Mac: sudo npm run / sudo yarn
  const devServerPort = 7002 // TODO: get this variable from setting.ts
  // const mockServerPort = 9528 // TODO: get this variable from setting.ts
  const name = '拖拽上传' // TODO: get this variable from setting.ts
  
  module.exports = {
    transpileDependencies: ['fuse.js'],
    publicPath: process.env.NODE_ENV === 'production' ? '/' : '/',
    lintOnSave: process.env.NODE_ENV === 'development',
    productionSourceMap: false,
    devServer: {
      port: devServerPort,
      open: true,
      overlay: {
        warnings: false,
        errors: true
      },
      progress: false,
      proxy: {
        // change xxx-api/login => /mock-api/v1/login
        // detail: https://cli.vuejs.org/config/#devserver-proxy
        [process.env.VUE_APP_BASE_API]: {
          // target: `http://localhost:${mockServerPort}/mock-api/v1`,
          target: process.env.VUE_APP_FULL_API,
          changeOrigin: true,
          ws: true,
          pathRewrite: {
            ['^' + process.env.VUE_APP_BASE_API]: ''
          }
        }
      },
      inline: false
    },
    pluginOptions: {
      'style-resources-loader': {
        preProcessor: 'less',
        patterns: [
          path.resolve(__dirname, 'src/styles/_variables.less'),
          path.resolve(__dirname, 'src/styles/_mixins.less')
        ],
        javascriptEnabled: true
      }
    },
    chainWebpack(config) {
      // provide the app's title in webpack's name field, so that
      // it can be accessed in index.html to inject the correct title.
      config.set('name', name)
  
      // it can improve the speed of the first screen, it is recommended to turn on preload
      config.plugin('preload').tap(() => [
        {
          rel: 'preload',
          // to ignore runtime.js
          // https://github.com/vuejs/vue-cli/blob/dev/packages/@vue/cli-service/lib/config/app.js#L171
          fileBlacklist: [/\.map$/, /hot-update\.js$/, /runtime\..*\.js$/],
          include: 'initial'
        }
      ])
  
      // https://webpack.js.org/configuration/devtool/#development
      // Change development env source map if you want.
      // The default in vue-cli is 'eval-cheap-module-source-map'.
      // config
      //   .when(process.env.NODE_ENV === 'development',
      //     config => config.devtool('eval-cheap-source-map')
      //   )
  
      config
        .when(process.env.NODE_ENV !== 'development',
          config => {
            config
              .optimization.splitChunks({
                chunks: 'all',
                cacheGroups: {
                  libs: {
                    name: 'chunk-libs',
                    test: /[\\/]node_modules[\\/]/,
                    priority: 10,
                    chunks: 'initial' // only package third parties that are initially dependent
                  },
                  viewDesign: {
                    name: 'chunk-viewDesign', // split viewDesign into a single package
                    priority: 20, // the weight needs to be larger than libs and app or it will be packaged into libs or app
                    test: /[\\/]node_modules[\\/]_?view-esign(.*)/ // in order to adapt to cnpm
                  },
                  commons: {
                    name: 'chunk-commons',
                    test: path.resolve(__dirname, 'src/components'),
                    minChunks: 3, //  minimum common number
                    priority: 5,
                    reuseExistingChunk: true
                  }
                }
              })
            // https://webpack.js.org/configuration/optimization/#optimizationruntimechunk
            config.optimization.runtimeChunk('single')
          }
        )
      if (process.env.use_analyzer) { // 分析
        config
          .plugin('webpack-bundle-analyzer')
          // eslint-disable-next-line @typescript-eslint/no-var-requires
          .use(require('webpack-bundle-analyzer').BundleAnalyzerPlugin)
      }
    },
    css: {
      loaderOptions: {
        less: {
          lessOptions: {
            javascriptEnabled: true
          }
        }
      }
    }
  }
  