Fix dynamic importing in production build
	
		
			
	
		
	
	
		
	
		
			All checks were successful
		
		
	
	
		
			
				
	
				continuous-integration/drone Build is passing
				
			
		
		
	
	
				
					
				
			
		
			All checks were successful
		
		
	
	continuous-integration/drone Build is passing
				
			This commit is contained in:
		
							
								
								
									
										19
									
								
								package-lock.json
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										19
									
								
								package-lock.json
									
									
									
										generated
									
									
									
								
							| @@ -31,6 +31,7 @@ | |||||||
|       "devDependencies": { |       "devDependencies": { | ||||||
|         "@vitejs/plugin-vue": "^3.0.3", |         "@vitejs/plugin-vue": "^3.0.3", | ||||||
|         "vite": "^3.0.9", |         "vite": "^3.0.9", | ||||||
|  |         "vite-plugin-dynamic-import": "^1.2.4", | ||||||
|         "vue-cli-plugin-vuetify": "~2.5.8", |         "vue-cli-plugin-vuetify": "~2.5.8", | ||||||
|         "webpack-plugin-vuetify": "^2.0.0-alpha.0" |         "webpack-plugin-vuetify": "^2.0.0-alpha.0" | ||||||
|       } |       } | ||||||
| @@ -7753,6 +7754,15 @@ | |||||||
|         } |         } | ||||||
|       } |       } | ||||||
|     }, |     }, | ||||||
|  |     "node_modules/vite-plugin-dynamic-import": { | ||||||
|  |       "version": "1.2.4", | ||||||
|  |       "resolved": "https://registry.npmjs.org/vite-plugin-dynamic-import/-/vite-plugin-dynamic-import-1.2.4.tgz", | ||||||
|  |       "integrity": "sha512-R6spqDhDm8VxaUNyEkybh9PM262ReO8WXJ6rjtyJ/H8Y4b+pq2uM9Xz5DMu7N7OxUGlqo9HSzT3VjhpbySXrng==", | ||||||
|  |       "dev": true, | ||||||
|  |       "dependencies": { | ||||||
|  |         "fast-glob": "~3.2.12" | ||||||
|  |       } | ||||||
|  |     }, | ||||||
|     "node_modules/vue": { |     "node_modules/vue": { | ||||||
|       "version": "3.2.39", |       "version": "3.2.39", | ||||||
|       "resolved": "https://registry.npmjs.org/vue/-/vue-3.2.39.tgz", |       "resolved": "https://registry.npmjs.org/vue/-/vue-3.2.39.tgz", | ||||||
| @@ -13641,6 +13651,15 @@ | |||||||
|         "rollup": "~2.78.0" |         "rollup": "~2.78.0" | ||||||
|       } |       } | ||||||
|     }, |     }, | ||||||
|  |     "vite-plugin-dynamic-import": { | ||||||
|  |       "version": "1.2.4", | ||||||
|  |       "resolved": "https://registry.npmjs.org/vite-plugin-dynamic-import/-/vite-plugin-dynamic-import-1.2.4.tgz", | ||||||
|  |       "integrity": "sha512-R6spqDhDm8VxaUNyEkybh9PM262ReO8WXJ6rjtyJ/H8Y4b+pq2uM9Xz5DMu7N7OxUGlqo9HSzT3VjhpbySXrng==", | ||||||
|  |       "dev": true, | ||||||
|  |       "requires": { | ||||||
|  |         "fast-glob": "~3.2.12" | ||||||
|  |       } | ||||||
|  |     }, | ||||||
|     "vue": { |     "vue": { | ||||||
|       "version": "3.2.39", |       "version": "3.2.39", | ||||||
|       "resolved": "https://registry.npmjs.org/vue/-/vue-3.2.39.tgz", |       "resolved": "https://registry.npmjs.org/vue/-/vue-3.2.39.tgz", | ||||||
|   | |||||||
| @@ -13,9 +13,9 @@ | |||||||
|     "@meforma/vue-toaster": "^1.3.0", |     "@meforma/vue-toaster": "^1.3.0", | ||||||
|     "@vue/cli-service": "^5.0.8", |     "@vue/cli-service": "^5.0.8", | ||||||
|     "ag-grid-vue3": "^28.2.0", |     "ag-grid-vue3": "^28.2.0", | ||||||
|  |     "ansi-to-html": "^0.7.2", | ||||||
|     "core-js": "^3.25.1", |     "core-js": "^3.25.1", | ||||||
|     "event-hooks-webpack-plugin": "^2.2.0", |     "event-hooks-webpack-plugin": "^2.2.0", | ||||||
|     "ansi-to-html": "^0.7.2", |  | ||||||
|     "pinia": "^2.0.21", |     "pinia": "^2.0.21", | ||||||
|     "roboto-fontface": "*", |     "roboto-fontface": "*", | ||||||
|     "single-spa-vue": "^2.5.1", |     "single-spa-vue": "^2.5.1", | ||||||
| @@ -31,6 +31,7 @@ | |||||||
|   "devDependencies": { |   "devDependencies": { | ||||||
|     "@vitejs/plugin-vue": "^3.0.3", |     "@vitejs/plugin-vue": "^3.0.3", | ||||||
|     "vite": "^3.0.9", |     "vite": "^3.0.9", | ||||||
|  |     "vite-plugin-dynamic-import": "^1.2.4", | ||||||
|     "vue-cli-plugin-vuetify": "~2.5.8", |     "vue-cli-plugin-vuetify": "~2.5.8", | ||||||
|     "webpack-plugin-vuetify": "^2.0.0-alpha.0" |     "webpack-plugin-vuetify": "^2.0.0-alpha.0" | ||||||
|   } |   } | ||||||
|   | |||||||
| @@ -5,7 +5,7 @@ metadata: | |||||||
|  |  | ||||||
| build: | build: | ||||||
|   artifacts: |   artifacts: | ||||||
|   - image: harbor.codemowers.eu/eaas/logmower-frontend |   - image: harbor.codemowers.eu/erkiaas/logmower-frontend | ||||||
|     docker: |     docker: | ||||||
|       dockerfile: Dockerfile |       dockerfile: Dockerfile | ||||||
|  |  | ||||||
| @@ -22,9 +22,9 @@ profiles: | |||||||
|       - command: dev |       - command: dev | ||||||
|     build: |     build: | ||||||
|       artifacts: |       artifacts: | ||||||
|         - image: harbor.codemowers.eu/eaas/logmower-frontend |         - image: harbor.k-space.ee/playground/logmower-frontend | ||||||
|           docker: |           docker: | ||||||
|             target: dev |             target: prod | ||||||
|           sync: |           sync: | ||||||
|             manual: |             manual: | ||||||
|               - src: 'src/**/*.vue' |               - src: 'src/**/*.vue' | ||||||
| @@ -39,4 +39,4 @@ profiles: | |||||||
|                 dest: . |                 dest: . | ||||||
|     manifests: |     manifests: | ||||||
|       rawYaml: |       rawYaml: | ||||||
|         - k8s/dev/deployment.yaml |         - k8s/dev/deployment-camtiler.yaml | ||||||
|   | |||||||
| @@ -90,8 +90,8 @@ export default { | |||||||
|     fetch('/events/backend') |     fetch('/events/backend') | ||||||
|         .then((response) => response.text()) |         .then((response) => response.text()) | ||||||
|         .then((response) => { |         .then((response) => { | ||||||
|           this.backend = response |           this.backend = response // TODO handle bad gateway etc | ||||||
|           import( /* @vite-ignore */  './Grid/Main/configs/' + response) |           import(`./Grid/Main/configs/${response}.js`) | ||||||
|               .then(module => { |               .then(module => { | ||||||
|                 this.defaultColDef = module.default.defaultColDef |                 this.defaultColDef = module.default.defaultColDef | ||||||
|                 this.columnDefs = module.default.columnDefs |                 this.columnDefs = module.default.columnDefs | ||||||
|   | |||||||
| @@ -1,9 +1,12 @@ | |||||||
| import vue from '@vitejs/plugin-vue' | import vue from '@vitejs/plugin-vue' | ||||||
|  | import dynamicImport from 'vite-plugin-dynamic-import' | ||||||
|  | import * as path from "path"; | ||||||
|  |  | ||||||
| export default { | export default { | ||||||
|   resolve: { |   resolve: { | ||||||
|     alias: { |     alias: { | ||||||
|       vue: 'vue/dist/vue.esm-bundler.js' |       vue: 'vue/dist/vue.esm-bundler.js', | ||||||
|  |       '@': path.join(__dirname, 'src/components/Grid/Main/configs'), | ||||||
|     } |     } | ||||||
|   }, |   }, | ||||||
|   rollupOptions: { |   rollupOptions: { | ||||||
| @@ -11,13 +14,16 @@ export default { | |||||||
|     format: 'system', |     format: 'system', | ||||||
|     preserveEntrySignatures: true |     preserveEntrySignatures: true | ||||||
|   }, |   }, | ||||||
|   plugins: [vue({ |   plugins: [ | ||||||
|     template: { |       vue({ | ||||||
|       transformAssetUrls: { |         template: { | ||||||
|         base: '/src' |           transformAssetUrls: { | ||||||
|       } |             base: '/src' | ||||||
|     } |           } | ||||||
|   })], |         }, | ||||||
|  |       }), | ||||||
|  |       dynamicImport(/* options */) | ||||||
|  |   ], | ||||||
|   pluginOptions: { |   pluginOptions: { | ||||||
|     vuetify: { |     vuetify: { | ||||||
|       // https://github.com/vuetifyjs/vuetify-loader/tree/next/packages/vuetify-loader |       // https://github.com/vuetifyjs/vuetify-loader/tree/next/packages/vuetify-loader | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user