vite.config.js 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /*
  2. * @Author: 半生瓜 1515706227@qq.com
  3. * @Date: 2023-10-18 10:46:30
  4. * @LastEditors: 半生瓜 1515706227@qq.com
  5. * @LastEditTime: 2024-03-11 19:07:53
  6. * @FilePath: \v3_yyz\vite.config.js
  7. * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
  8. */
  9. import { defineConfig } from 'vite'
  10. import vue from '@vitejs/plugin-vue'
  11. import AutoImport from 'unplugin-auto-import/vite'
  12. import Components from 'unplugin-vue-components/vite'
  13. import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'
  14. import postCssPxToRem from "postcss-pxtorem";
  15. export default defineConfig({
  16. assetsDir: "static",
  17. publicPath: "./", // 确保所有静态资源的路径都是相对于根路径的
  18. resolve: {
  19. alias: {
  20. '@': '/src',
  21. },
  22. },
  23. base: './',//相对路径
  24. build: {
  25. minify: 'terser',
  26. terserOptions: {
  27. compress: {
  28. //生产环境时移除console
  29. drop_console: true,
  30. drop_debugger: true,
  31. }
  32. }
  33. },
  34. server:{
  35. host:'0.0.0.0',
  36. },
  37. plugins: [
  38. vue(),
  39. Components({
  40. resolvers: [ElementPlusResolver()]
  41. }),
  42. AutoImport({
  43. resolvers: [ElementPlusResolver()]
  44. }),
  45. ],
  46. css: {
  47. postcss:
  48. {
  49. plugins:
  50. [postCssPxToRem({
  51. rootValue: 192,
  52. // 1rem,根据 设计稿宽度/10 进行设置
  53. propList: ['*']
  54. // 需要转换的属性,这里选择全部都进行转换
  55. })]
  56. }
  57. },
  58. configureWebpack: (config) => {
  59. console.log("config");
  60. config.module.rules.push(
  61. {
  62. test: path.resolve(__dirname, 'node_modules/leader-line/'),
  63. use: [{
  64. loader: 'skeleton-loader',
  65. options: { procedure: content => `${content}export default LeaderLine` }
  66. }]
  67. }
  68. )
  69. },
  70. })