Skip to content

Commit

Permalink
Merge pull request #27346 from mshima/resolve
Browse files Browse the repository at this point in the history
simplify vite.config using import.meta.resolve
  • Loading branch information
DanielFran authored Oct 2, 2024
2 parents 3a5bd89 + 9c77791 commit ed25314
Showing 1 changed file with 1 addition and 7 deletions.
8 changes: 1 addition & 7 deletions generators/vue/templates/vite.config.mts.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
limitations under the License.
-%>
import { fileURLToPath, URL } from 'node:url';
import { existsSync } from 'node:fs';
import { normalizePath } from 'vite'

import {
Expand All @@ -36,11 +35,6 @@ const sharedAppVersion = '0.0.0';
<%_ } _%>
<%_ } _%>

const getFileFromRepo = (file: string) =>
existsSync(fileURLToPath(new URL(`../node_modules/${file}`, import.meta.url)))
? fileURLToPath(new URL(`../node_modules/${file}`, import.meta.url))
: fileURLToPath(new URL(`./node_modules/${file}`, import.meta.url));

const { getAbsoluteFSPath } = await import('swagger-ui-dist');
const swaggerUiPath = getAbsoluteFSPath();

Expand All @@ -54,7 +48,7 @@ let config = defineConfig({
src: [
`${normalizePath(swaggerUiPath)}/*.{js,css,html,png}`,
`!${normalizePath(swaggerUiPath)}/**/index.html`,
normalizePath(getFileFromRepo('axios/dist/axios.min.js')),
normalizePath(fileURLToPath(new URL('./dist/axios.min.js', import.meta.resolve('axios/package.json')))),
normalizePath(fileURLToPath(new URL('./<%- this.relativeDir(clientRootDir, clientSrcDir) %>swagger-ui/index.html', import.meta.url))),
],
dest: 'swagger-ui',
Expand Down

0 comments on commit ed25314

Please sign in to comment.