buildchain/vite.config.ts   A
last analyzed

Complexity

Total Complexity 1
Complexity/F 0

Size

Lines of Code 91
Function Count 0

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
wmc 1
eloc 67
c 0
b 0
f 0
dl 0
loc 91
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
        'content-seo': 'src/js/content-seo.js',
21
        'seomatic': 'src/js/seomatic.js',
22
        'seomatic-meta': 'src/js/seomatic-meta.js',
23
      },
24
    },
25
    sourcemap: true
26
  },
27
  plugins: [
28
    createVuePlugin(),
29
    viteExternalsPlugin({
30
      'vue': 'Vue',
31
    }),
32
    viteCompressionPlugin({
33
      filter: /\.(js|mjs|json|css|map)$/i
34
    }),
35
    visualizer({
36
      filename: '../src/web/assets/dist/stats.html',
37
      template: 'treemap',
38
      sourcemap: true,
39
    }),
40
    tailwindcss(),
41
    checker({
42
      eslint: {
43
        lintCommand: 'eslint "./src/**/*.{js,ts}"',
44
        useFlatConfig: true,
45
        dev: {
46
          overrideConfig: {
47
            cache: true,
48
          }
49
        }
50
      },
51
      stylelint: {
52
        lintCommand: 'stylelint ./src/**/*.{css,scss,sass,pcss} --fix',
53
        dev: {
54
          overrideConfig: {
55
            cache: true,
56
          }
57
        }
58
      },
59
      typescript: true,
60
      vueTsc: true,
61
    }),
62
  ],
63
  optimizeDeps: {
64
    include: ['vue-confetti', 'vue-apexcharts', 'vue-axios', '@riophae/vue-treeselect'],
65
  },
66
  resolve: {
67
    alias: [
68
      {find: '@', replacement: path.resolve(__dirname, './src')},
69
      {find: 'vue', replacement: 'vue/dist/vue.esm.js'},
70
    ],
71
    preserveSymlinks: true,
72
  },
73
  server: {
74
    // Allow cross-origin requests -- https://github.com/vitejs/vite/security/advisories/GHSA-vg6x-rcgg-rjx6
75
    allowedHosts: true,
76
    cors: {
77
      origin: /https?:\/\/([A-Za-z0-9\-\.]+)?(localhost|\.local|\.test|\.ddev\.site)(?::\d+)?$/
78
    },
79
    fs: {
80
      strict: false
81
    },
82
    headers: {
83
      "Access-Control-Allow-Private-Network": "true",
84
    },
85
    host: '0.0.0.0',
86
    origin: 'http://localhost:' + process.env.DEV_PORT,
87
    port: parseInt(process.env.DEV_PORT),
88
    strictPort: true,
89
  }
90
}));
91