aboutsummaryrefslogtreecommitdiff
path: root/vite.config.ts
diff options
context:
space:
mode:
Diffstat (limited to 'vite.config.ts')
-rw-r--r--vite.config.ts130
1 files changed, 77 insertions, 53 deletions
diff --git a/vite.config.ts b/vite.config.ts
index d53d630..b37dade 100644
--- a/vite.config.ts
+++ b/vite.config.ts
@@ -2,64 +2,88 @@ import { defineConfig } from 'vite';
import vue from '@vitejs/plugin-vue';
import path from 'path';
import rawPlugin from 'vite-plugin-raw';
+import { viteStaticCopy } from 'vite-plugin-static-copy';
-export default defineConfig(({ mode }) => {
- return {
- plugins: [
- vue({
- template: {
- compilerOptions: {
- isCustomElement: tag => ['altcha-widget'].includes(tag)
- }
+export default defineConfig(({ mode }) => ({
+ plugins: [
+ vue({
+ template: {
+ compilerOptions: {
+ isCustomElement: tag => ['altcha-widget'].includes(tag)
}
- }),
- rawPlugin({
- match: /ckeditor5-[^/\\]+[/\\]theme[/\\]icons[/\\][^/\\]+\.svg$/,
- exclude: undefined
- })
- ],
- resolve: {
- alias: {
- '@': path.resolve(__dirname, 'resources'),
- 'jquery-ui': 'jquery-ui'
}
- },
- build: {
- outDir: 'public/assets',
- emptyOutDir: false,
- rollupOptions: {
- input: {
- 'studip-base': path.resolve(__dirname, 'resources/assets/javascripts/entry-base.js'),
- 'studip-statusgroups': path.resolve(__dirname, 'resources/assets/javascripts/entry-statusgroups.js'),
- 'studip-wysiwyg': path.resolve(__dirname, 'resources/assets/javascripts/entry-wysiwyg.js'),
- 'studip-installer': path.resolve(__dirname, 'resources/assets/javascripts/entry-installer.js'),
- 'print': path.resolve(__dirname, 'resources/assets/stylesheets/print.scss'),
- 'accessibility': path.resolve(__dirname, 'resources/assets/stylesheets/highcontrast.scss')
+ }),
+ rawPlugin({
+ match: /ckeditor5-[^/\\]+[\\/]+theme[\\/]+icons[\\/]+[^/\\]+\.svg$/,
+ exclude: /.*/
+ }),
+ viteStaticCopy({
+ targets: [
+ {
+ src: 'node_modules/vue/dist/vue.global.prod.js',
+ dest: 'javascripts'
},
- external: ['vue', 'vuex'],
- output: {
- entryFileNames: info => info.name.includes('entry-') ? 'javascripts/[name].js' : 'stylesheets/[name].js',
- chunkFileNames: 'javascripts/[name].chunk.js?h=[hash]',
- assetFileNames: assetInfo => {
- if (assetInfo.name?.endsWith('.css')) {
- return 'stylesheets/[name][extname]';
- }
- return '[name][extname]';
- }
+ {
+ src: 'node_modules/vuex/dist/vuex.global.prod.js',
+ dest: 'javascripts'
}
+ ]
+ })
+ ],
+ resolve: {
+ alias: {
+ '@': path.resolve(__dirname, 'resources'),
+ 'jquery-ui': 'jquery-ui'
+ }
+ },
+ publicDir: false,
+ build: {
+ outDir: 'public/assets',
+ emptyOutDir: false,
+ sourcemap: mode !== 'production',
+ rollupOptions: {
+ input: {
+ 'studip-base': path.resolve(__dirname, 'resources/assets/javascripts/entry-base.js'),
+ 'studip-statusgroups': path.resolve(__dirname, 'resources/assets/javascripts/entry-statusgroups.js'),
+ 'studip-wysiwyg': path.resolve(__dirname, 'resources/assets/javascripts/entry-wysiwyg.js'),
+ 'studip-installer': path.resolve(__dirname, 'resources/assets/javascripts/entry-installer.js'),
+ 'print': path.resolve(__dirname, 'resources/assets/stylesheets/print.scss'),
+ 'accessibility': path.resolve(__dirname, 'resources/assets/stylesheets/highcontrast.scss')
},
- sourcemap: mode !== 'production'
- },
- css: {
- postcss: './postcss.config.js',
- preprocessorOptions: {
- scss: {}
+ external: ['vue', 'vuex'],
+ output: {
+ format: 'iife',
+ entryFileNames: 'javascripts/[name].js',
+ chunkFileNames: 'javascripts/[name].chunk.js?h=[hash]',
+ assetFileNames: assetInfo => {
+ const name = assetInfo.name || '';
+ if (name.endsWith('.css')) {
+ return 'stylesheets/[name][extname]';
+ }
+ if (/\.(woff2?|ttf|eot)$/.test(name)) {
+ return 'fonts/[name][extname]';
+ }
+ if (/\.(png|jpe?g|svg|gif|webp)$/.test(name)) {
+ return 'images/[name][extname]';
+ }
+ return 'javascripts/[name][extname]';
+ },
+ globals: {
+ vue: 'Vue',
+ vuex: 'Vuex'
+ }
}
- },
- define: {
- __VUE_OPTIONS_API__: true,
- __VUE_PROD_DEVTOOLS__: mode !== 'production',
- __VUE_PROD_HYDRATION_MISMATCH_DETAILS__: mode !== 'production'
}
- };
-});
+ },
+ css: {
+ postcss: './postcss.config.js',
+ preprocessorOptions: {
+ scss: {}
+ }
+ },
+ define: {
+ __VUE_OPTIONS_API__: true,
+ __VUE_PROD_DEVTOOLS__: mode !== 'production',
+ __VUE_PROD_HYDRATION_MISMATCH_DETAILS__: mode !== 'production'
+ }
+}));