vite.config.ts 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. import { defineConfig } from 'vite';
  2. import vue from '@vitejs/plugin-vue';
  3. import Markdown from 'vite-plugin-md';
  4. import path from 'path';
  5. import legacy from '@vitejs/plugin-legacy';
  6. const resolve = path.resolve;
  7. // https://vitejs.dev/config/
  8. export default defineConfig({
  9. server: {
  10. proxy: {
  11. '/devServer': {
  12. target: 'http://nutui-server.jd.com',
  13. changeOrigin: true,
  14. rewrite: path => path.replace(/^\/devServer/, '')
  15. }
  16. }
  17. },
  18. resolve: {
  19. alias: [{ find: '@', replacement: resolve(__dirname, './src') }]
  20. },
  21. css: {
  22. preprocessorOptions: {
  23. scss: {
  24. // example : additionalData: `@import "./src/design/styles/variables";`
  25. // dont need include file extend .scss
  26. additionalData: `@import "@/styles/variables.scss";@import "@/sites/assets/styles/variables.scss";`
  27. }
  28. }
  29. },
  30. plugins: [
  31. vue({
  32. include: [/\.vue$/, /\.md$/]
  33. }),
  34. Markdown(),
  35. legacy({
  36. targets: ['defaults', 'not IE 11']
  37. })
  38. ],
  39. build: {
  40. cssCodeSplit: false,
  41. rollupOptions: {
  42. input: {
  43. doc: resolve(__dirname, 'index.html'),
  44. mobile: resolve(__dirname, 'demo.html')
  45. }
  46. }
  47. }
  48. });