buildchain/vite.config.ts   A
last analyzed

Complexity

Total Complexity 1
Complexity/F 0

Size

Lines of Code 93
Function Count 0

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
wmc 1
eloc 69
c 0
b 0
f 0
dl 0
loc 93
rs 10
mnd 1
bc 1
fnc 0
bpm 0
cpm 0
noi 0
1
import createVuePlugin from '@vitejs/plugin-vue2';
2
import {defineConfig} from 'vite';
3
import checker from 'vite-plugin-checker';
4
import tailwindcss from "@tailwindcss/vite";
5
import {visualizer} from 'rollup-plugin-visualizer';
6
import viteCompressionPlugin from 'vite-plugin-compression';
7
import {viteExternalsPlugin} from 'vite-plugin-externals';
8
import * as path from 'path';
9
10
// https://vitejs.dev/config/
11
export default defineConfig(({command}) => ({
12
  base: command === 'serve' ? '' : '/dist/',
13
  build: {
14
    emptyOutDir: true,
15
    manifest: 'manifest.json',
16
    outDir: '../src/web/assets/dist',
17
    rollupOptions: {
18
      input: {
19
        'dashboard': 'src/js/Dashboard.js',
20
        'import': 'src/js/Import.js',
21
        'redirects': 'src/js/Redirects.js',
22
        'retour': 'src/js/Retour.js',
23
        'shortlinks': 'src/js/Shortlinks.js',
24
        'widget': 'src/js/Widget.js'
25
      },
26
    },
27
    sourcemap: true
28
  },
29
  plugins: [
30
    createVuePlugin(),
31
    viteExternalsPlugin({
32
      'vue': 'Vue',
33
    }),
34
    viteCompressionPlugin({
35
      filter: /\.(js|mjs|json|css|map)$/i
36
    }),
37
    visualizer({
38
      filename: '../src/web/assets/dist/stats.html',
39
      template: 'treemap',
40
      sourcemap: true,
41
    }),
42
    tailwindcss(),
43
    checker({
44
      eslint: {
45
        lintCommand: 'eslint "./src/**/*.{js,ts}"',
46
        useFlatConfig: true,
47
        dev: {
48
          overrideConfig: {
49
            cache: true,
50
          }
51
        }
52
      },
53
      stylelint: {
54
        lintCommand: 'stylelint ./src/**/*.{css,scss,sass,pcss} --fix',
55
        dev: {
56
          overrideConfig: {
57
            cache: true,
58
          }
59
        }
60
      },
61
      typescript: true,
62
      vueTsc: true,
63
    }),
64
  ],
65
  optimizeDeps: {
66
    include: ['vue-confetti', 'vue-apexcharts', 'vue-save-state'],
67
  },
68
  resolve: {
69
    alias: [
70
      {find: '@', replacement: path.resolve(__dirname, './src')},
71
      {find: 'vue', replacement: 'vue/dist/vue.esm.js'},
72
    ],
73
    preserveSymlinks: true,
74
  },
75
  server: {
76
    // Allow cross-origin requests -- https://github.com/vitejs/vite/security/advisories/GHSA-vg6x-rcgg-rjx6
77
    allowedHosts: true,
78
    cors: {
79
      origin: /https?:\/\/([A-Za-z0-9\-\.]+)?(localhost|\.local|\.test|\.ddev\.site)(?::\d+)?$/
80
    },
81
    fs: {
82
      strict: false
83
    },
84
    headers: {
85
      "Access-Control-Allow-Private-Network": "true",
86
    },
87
    host: '0.0.0.0',
88
    origin: 'http://localhost:' + process.env.DEV_PORT,
89
    port: parseInt(process.env.DEV_PORT),
90
    strictPort: true,
91
  }
92
}));
93