const { resolve } = require('path')
const { VantResolver } = require('unplugin-vue-components/resolvers')
const ComponentsPlugin = require('unplugin-vue-components/webpack')

module.exports = {
  publicPath: '/app_web', // 打包后资源访问路径
  lintOnSave: false, // eslint是否在保存的时候检查
  pages: {
    index: {
      entry: 'src/main.ts', // page 的入口
      template: 'public/index.html', // 模板来源
      filename: 'index.html' //  在 dist/index.html 的输出
    },
    demo: {
      entry: 'src/pages/demo/main.ts',
      template: 'src/pages/demo/public/index.html',
      filename: 'demo.html'
    },
    LearnPlan: {
      entry: 'src/pages/LearnPlan/main.ts',
      template: 'src/pages/LearnPlan/public/index.html',
      filename: 'learn-plan.html'
    }
  },
  chainWebpack: config => {
    config.resolve.alias
      .set('@', resolve('src'))
      .set('@hook', resolve('src/hook'))
      .set('@demo', resolve('src/pages/demo/src'))
      .set('@LP', resolve('src/pages/LearnPlan'))
  },
  configureWebpack: {
    plugins: [
      ComponentsPlugin({
        resolvers: [VantResolver()]
      })
    ]
  },
  devServer: {
    proxy: {
      "/api/": {
        target: "http://local.luojigou.vip:8888/", 
        ws: false,
        secure: false,
        changeOrigin: true,
        pathRewrite: {
          "^/api/": ""
        }
      },
    }
  },
}
