Passed
Push — develop ( f378f1...d9ad9e )
by Andrew
09:21 queued 03:25
created

buildchain/vite.config.ts   A

Complexity

Total Complexity 1
Complexity/F 0

Size

Lines of Code 81
Function Count 0

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
wmc 1
eloc 61
c 0
b 0
f 0
dl 0
loc 81
rs 10
mnd 1
bc 1
fnc 0
bpm 0
cpm 0
noi 0
1
import {defineConfig} from 'vite';
2
import {createVuePlugin} from 'vite-plugin-vue2'
3
import ViteRestart from 'vite-plugin-restart';
4
import {viteExternalsPlugin} from 'vite-plugin-externals'
5
import viteCompression from 'vite-plugin-compression';
6
import manifestSRI from 'vite-plugin-manifest-sri';
7
import {visualizer} from 'rollup-plugin-visualizer';
8
import eslintPlugin from 'vite-plugin-eslint';
9
import {nodeResolve} from '@rollup/plugin-node-resolve';
10
import * as path from 'path';
11
12
// https://vitejs.dev/config/
13
export default defineConfig(({command}) => ({
14
  base: command === 'serve' ? '' : '/dist/',
15
  build: {
16
    emptyOutDir: true,
17
    manifest: true,
18
    outDir: '../src/web/assets/dist',
19
    rollupOptions: {
20
      input: {
21
        'alerts': 'src/js/alerts.js',
22
        'dashboard': 'src/js/dashboard.js',
23
        'errors-detail': 'src/js/errors-detail.js',
24
        'errors-index': 'src/js/errors-index.js',
25
        'performance-detail': 'src/js/performance-detail.js',
26
        'performance-index': 'src/js/performance-index.js',
27
        'sidebar': 'src/js/sidebar.js',
28
        'webperf': 'src/js/webperf.js',
29
      },
30
      output: {
31
        sourcemap: true
32
      },
33
    }
34
  },
35
  plugins: [
36
    nodeResolve({
37
      moduleDirectories: [
38
        path.resolve('./node_modules'),
39
      ],
40
    }),
41
    ViteRestart({
42
      reload: [
43
        './src/templates/**/*',
44
      ],
45
    }),
46
    createVuePlugin(),
47
    viteExternalsPlugin({
48
      'vue': 'Vue',
49
    }),
50
    viteCompression({
51
      filter: /\.(js|mjs|json|css|map)$/i
52
    }),
53
    manifestSRI(),
54
    visualizer({
55
      filename: '../src/web/assets/dist/stats.html',
56
      template: 'treemap',
57
      sourcemap: true,
58
    }),
59
    eslintPlugin({
60
      cache: false,
61
    }),
62
  ],
63
  publicDir: '../src/web/assets/public',
64
  resolve: {
65
    alias: {
66
      '@': path.resolve(__dirname, './src'),
67
      'vue': 'vue/dist/vue.esm.js',
68
    },
69
    preserveSymlinks: true,
70
  },
71
  server: {
72
    fs: {
73
      strict: false
74
    },
75
    host: '0.0.0.0',
76
    origin: 'http://localhost:3001/',
77
    port: 3001,
78
    strictPort: true,
79
  }
80
}));
81