猎户系统

vue.config.js 2.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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. const Timestamp= new Date().getTime()
  9. function resolve (dir) {
  10. return path.join(__dirname, dir)
  11. }
  12. module.exports = defineConfig({
  13. transpileDependencies: true,
  14. devServer: {
  15. proxy: { // 配置跨域
  16. '/api': {
  17. target: 'http://yhq.wenxingshuju.com', // 测试环境
  18. // target: 'http://lh.wenxingshuju.com', // 生产环境
  19. changeOrigin: true, // 允许跨域
  20. pathRewrite: {
  21. '^/api': '' // 请求的时候使用这个api就可以
  22. }
  23. }
  24. }
  25. },
  26. lintOnSave: false,
  27. publicPath: process.env.NODE_ENV === 'production' ? './' : '/',
  28. outputDir: 'dist',
  29. productionSourceMap: false,//打包不到.map文件
  30. configureWebpack: {
  31. // provide the app's title in webpack's name field, so that
  32. // it can be accessed in index.html to inject the correct title.
  33. resolve: {
  34. alias: {
  35. '@': resolve('src')
  36. }
  37. },
  38. output: { // 输出重构 打包编译后的 文件名称
  39. filename: `js/[name].${Timestamp}.js`,
  40. chunkFilename: `js/[name].${Timestamp}.js`
  41. },
  42. // css: { // css 配置
  43. // extract: {
  44. // // 修改打包后css文件名
  45. // filename: `css/[name].${Timestamp}.css`,
  46. // chunkFilename: `css/[name].${Timestamp}.css`
  47. // }
  48. // },
  49. plugins: [
  50. AutoImport({
  51. resolvers: [ElementPlusResolver()],
  52. }),
  53. Components({
  54. resolvers: [ElementPlusResolver(), VantResolver()],
  55. }),
  56. ElementPlus(),
  57. new CompressionPlugin({
  58. test: /\.js$|\.html$|\.css/, //匹配文件名
  59. threshold: 10240, //对超过10k的数据进行压缩
  60. deleteOriginalAssets: false //是否删除原文件
  61. }),
  62. ],
  63. },
  64. })