优惠券 PC管理端 项目

vue.config.js 2.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. const { defineConfig } = require('@vue/cli-service')
  2. const path = require('path')
  3. const AutoImport = require('unplugin-auto-import/webpack')
  4. const Components = require('unplugin-vue-components/webpack')
  5. const { ElementPlusResolver, VantResolver } = require('unplugin-vue-components/resolvers')
  6. const ElementPlus = require('unplugin-element-plus/webpack')
  7. const CompressionPlugin = require('compression-webpack-plugin')
  8. function resolve (dir) {
  9. return path.join(__dirname, dir)
  10. }
  11. module.exports = defineConfig({
  12. transpileDependencies: true,
  13. devServer: {
  14. proxy: { // 配置跨域
  15. '/api': {
  16. // target: 'http://yhq.wenxingshuju.com', // 线上
  17. // target: 'http://192.168.0.184:9009', // 后端本地
  18. // target: 'http://39.106.149.78:9009', // 测试环境
  19. target: 'http://yhq-test.wenxingshuju.com', // 测试环境
  20. changeOrigin: true, // 允许跨域
  21. pathRewrite: {
  22. '^/api': '' // 请求的时候使用这个api就可以
  23. }
  24. }
  25. }
  26. },
  27. lintOnSave: false,
  28. publicPath: process.env.NODE_ENV === 'production' ? './' : '/',
  29. outputDir: 'dist',
  30. productionSourceMap: false,//打包不到.map文件
  31. configureWebpack: {
  32. // provide the app's title in webpack's name field, so that
  33. // it can be accessed in index.html to inject the correct title.
  34. resolve: {
  35. alias: {
  36. '@': resolve('src')
  37. },
  38. },
  39. plugins: [
  40. AutoImport({
  41. resolvers: [ElementPlusResolver()],
  42. }),
  43. Components({
  44. resolvers: [ElementPlusResolver(), VantResolver()],
  45. }),
  46. ElementPlus(),
  47. new CompressionPlugin({
  48. test: /\.js$|\.html$|\.css/, //匹配文件名
  49. threshold: 10240, //对超过10k的数据进行压缩
  50. deleteOriginalAssets: false //是否删除原文件
  51. }),
  52. ],
  53. },
  54. chainWebpack (config) {
  55. // set svg-sprite-loader
  56. config.module
  57. .rule('svg')
  58. .exclude.add(resolve('src/assets/svg')) // 存放 svg 目录的目录
  59. .end()
  60. config.module
  61. .rule('icons')
  62. .test(/\.svg$/)
  63. .include.add(resolve('src/assets/svg')) // 存放 svg 目录的目录
  64. .end()
  65. .use('svg-sprite-loader')
  66. .loader('svg-sprite-loader')
  67. .options({
  68. symbolId: 'icon-[name]'
  69. })
  70. .end()
  71. },
  72. })