const path = require("path");
const webpack = require("webpack");
const px2rem = require("postcss-px2rem");
function resolve(dir) {
  return path.join(__dirname, dir);
}

// 配置基本大小
const postcss = px2rem({
  // 基准大小 baseSize,需要和rem.js中相同
  remUnit: 16,
});

module.exports = {
  configureWebpack: {
    plugins: [
      new webpack.ProvidePlugin({
        $: "jquery",
        jQuery: "jquery",
        "windows.jQuery": "jquery",
      }),
    ],
  },

  lintOnSave: false,
  runtimeCompiler: true,
  publicPath: process.env.NODE_ENV === "production" ? "./" : "/",

  // outputDir: "distTaxi",
  chainWebpack: (config) => {
    config.resolve.alias.set("@", resolve("src"));
    config.module
      .rule("pug")
      .test(/\.pug$/)
      .use("pug-html-loader")
      .loader("pug-html-loader")
      .end();
  },

  css: {
    loaderOptions: {
      postcss: {
        plugins: [postcss],
      },
    },
  },

  devServer: {
    proxy: {
      "/api": {
        target: "http://sit.dpfserv.datoubao365.cn",
        ws: false,
        changeOrigin: true,
        pathRewrite: {
          "^/api": "/",
        },
      },
    },
  },

  pluginOptions: {
    "style-resources-loader": {
      preProcessor: "less",
      patterns: [path.resolve(__dirname, "./src/assets/css/variable.less")],
    },
  },
};