diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-12-01 18:10:12 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-12-01 18:10:12 +0300 |
commit | c3ddbeb162e4261f4ce3df291909fadeba637995 (patch) | |
tree | 374741e3458db992f944819c5cc9f11ed3aa3a4a /vite.config.js | |
parent | 79c94e595b13bd4b4522e725e6096a41ff1a27ec (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'vite.config.js')
-rw-r--r-- | vite.config.js | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/vite.config.js b/vite.config.js index b4b35e10fda..88d264531a6 100644 --- a/vite.config.js +++ b/vite.config.js @@ -3,6 +3,7 @@ import { defineConfig } from 'vite'; import vue from '@vitejs/plugin-vue2'; import graphql from '@rollup/plugin-graphql'; import RubyPlugin from 'vite-plugin-ruby'; +import chokidar from 'chokidar'; import { viteCommonjs } from '@originjs/vite-plugin-commonjs'; import webpackConfig from './config/webpack.config'; import { @@ -58,6 +59,23 @@ const JH_ALIAS_FALLBACK = [ }, ]; +const autoRestartPlugin = { + configureServer(server) { + const watcher = chokidar.watch(['node_modules/.yarn-integrity'], { + ignoreInitial: true, + }); + + // GDK will restart Vite server for us + const stop = () => server.stop(); + + watcher.on('add', stop); + watcher.on('change', stop); + watcher.on('unlink', stop); + + server.httpServer?.addListener?.('close', () => watcher.close()); + }, +}; + export default defineConfig({ cacheDir: path.resolve(__dirname, 'tmp/cache/vite'), resolve: { @@ -76,6 +94,8 @@ export default defineConfig({ ], }, plugins: [ + // VITE_ENABLED is present when running with GDK + process.env.VITE_ENABLED ? autoRestartPlugin : null, fixedRubyPlugin, vue({ template: { |