vite.config.js 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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. base: './',//相对路径
  17. build: {
  18. minify: 'terser',
  19. terserOptions: {
  20. compress: {
  21. //生产环境时移除console
  22. drop_console: true,
  23. drop_debugger: true,
  24. }
  25. }
  26. },
  27. server:{
  28. host:'0.0.0.0',
  29. },
  30. plugins: [
  31. vue(),
  32. Components({
  33. resolvers: [ElementPlusResolver()]
  34. }),
  35. AutoImport({
  36. resolvers: [ElementPlusResolver()]
  37. }),
  38. ],
  39. css: {
  40. postcss:
  41. {
  42. plugins:
  43. [postCssPxToRem({
  44. rootValue: 192,
  45. // 1rem,根据 设计稿宽度/10 进行设置
  46. propList: ['*']
  47. // 需要转换的属性,这里选择全部都进行转换
  48. })]
  49. }
  50. },
  51. configureWebpack: (config) => {
  52. console.log("config");
  53. config.module.rules.push(
  54. {
  55. test: path.resolve(__dirname, 'node_modules/leader-line/'),
  56. use: [{
  57. loader: 'skeleton-loader',
  58. options: { procedure: content => `${content}export default LeaderLine` }
  59. }]
  60. }
  61. )
  62. },
  63. })