'use strict';
const path = require('path');
function resolve(dir) {
  return path.join(__dirname, dir);
}
const name = process.env.VUE_APP_TITLE || '门店拜访'; // 网页标题
const port = 8888; // 端口
module.exports = {
  parallel: false, // 强制关闭多线程构建
  publicPath: process.env.NODE_ENV === 'development' ? '/releaseMobile/' : '/mobile/',
  // publicPath: '/mobile/',
  outputDir: process.env.NODE_ENV === 'development' ? 'releaseMobile' : 'mobile',
  assetsDir: 'static',
  lintOnSave: false,
  productionSourceMap: false,
  devServer: {
    port: port,
    open: true,
    proxy: {
      [process.env.VUE_APP_BASE_API]: {
        target: process.env.VUE_APP_Target,
        changeOrigin: true,
        pathRewrite: {
          ['^' + process.env.VUE_APP_BASE_API]: process.env.VUE_APP_BASE_API + '',
        },
      },
    },
    disableHostCheck: true,
  },
  configureWebpack: {
    name: name,
    resolve: {
      alias: {
        '@': resolve('src'),
      },
    },
  },
  chainWebpack(config) {
    config.plugins.delete('preload'); // TODO: need test
    config.plugins.delete('prefetch'); // TODO: need test
    config.when(process.env.NODE_ENV !== 'development', (config) => {
      config.optimization.runtimeChunk('single'),
        {
          from: path.resolve(__dirname, './public/robots.txt'), //防爬虫文件
          to: './', //到根目录下
        };
    });
  },
  css: {
    loaderOptions: {
      sass: {
        // 使用 Dart Sass 配置
        implementation: require('sass'),
        // 更新为 additionalData 语法
        additionalData: `@use "@/assets/styles/variable.scss" as *;`,
      },
    },
  },
};
