vite.config.js 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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. plugins: [
  28. vue(),
  29. Components({
  30. resolvers: [ElementPlusResolver()]
  31. }),
  32. AutoImport({
  33. resolvers: [ElementPlusResolver()]
  34. }),
  35. ],
  36. css: {
  37. postcss:
  38. {
  39. plugins:
  40. [postCssPxToRem({
  41. rootValue: 192,
  42. // 1rem,根据 设计稿宽度/10 进行设置
  43. propList: ['*']
  44. // 需要转换的属性,这里选择全部都进行转换
  45. })]
  46. }
  47. },
  48. configureWebpack: (config) => {
  49. console.log("config");
  50. config.module.rules.push(
  51. {
  52. test: path.resolve(__dirname, 'node_modules/leader-line/'),
  53. use: [{
  54. loader: 'skeleton-loader',
  55. options: { procedure: content => `${content}export default LeaderLine` }
  56. }]
  57. }
  58. )
  59. },
  60. })