Skip to content

Commit

Permalink
fix: directory structure
Browse files Browse the repository at this point in the history
  • Loading branch information
markmartirosian committed Jul 9, 2023
1 parent e659dd0 commit 6f31cb6
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 6 deletions.
7 changes: 5 additions & 2 deletions packages/yeux/src/commands/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,17 @@ export const clientConfig = async (state: State): Promise<ViteInlineConfig> => {
return '[name].js'
}

return path.join(current.build.assetsDir, '[name]-[hash].js')
return path.join(
current.build.assetsDir,
'js/[name]-[hash].js'
)
},
assetFileNames:
options.assetFileNames ??
((asset: PreRenderedAsset) => assetFileNames(asset.name)),
chunkFileNames: path.join(
current.build.assetsDir,
'[name]-[hash].js'
'js/[name]-[hash].js'
)
})
)
Expand Down
52 changes: 48 additions & 4 deletions packages/yeux/src/utilities/create-asset-file-names.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import path from 'node:path'
export const extensionImage = [
'3dv',
'PI1',
'apng',
'PI2',
'PI3',
'ai',
Expand Down Expand Up @@ -48,7 +49,6 @@ export const extensionImage = [
'heif',
'icns',
'ico',
'ico',
'iff',
'iff',
'int',
Expand Down Expand Up @@ -132,6 +132,38 @@ export const extensionImage = [

export const extensionFont = ['eot', 'otf', 'ttc', 'ttf', 'woff', 'woff2']

export const extensionJavaScript = [
'.mjs',
'.js',
'.mts',
'.ts',
'.jsx',
'.tsx',
'.json'
]

export const extensionCSS = [
'css',
'less',
'sass',
'scss',
'styl',
'stylus',
'pcss',
'postcss'
]

export const extensionMedia = [
'mp4',
'webm',
'ogg',
'mp3',
'wav',
'flac',
'aac',
'opus'
]

const assetFileNameReturn = (assetsDir: string, type?: string) => {
if (type === undefined) {
return path.join(assetsDir, '[name]-[hash].[ext]')
Expand All @@ -152,12 +184,24 @@ export const createAssetFileNames =
}

if (hasExtension(filename, extensionImage)) {
return assetFileNameReturn(assetsDir, 'images')
return assetFileNameReturn(assetsDir, 'image')
}

if (hasExtension(filename, extensionFont)) {
return assetFileNameReturn(assetsDir, 'fonts')
return assetFileNameReturn(assetsDir, 'font')
}

if (hasExtension(filename, extensionJavaScript)) {
return assetFileNameReturn(assetsDir, 'js')
}

if (hasExtension(filename, extensionCSS)) {
return assetFileNameReturn(assetsDir, 'css')
}

if (hasExtension(filename, extensionMedia)) {
return assetFileNameReturn(assetsDir, 'media')
}

return assetFileNameReturn(assetsDir)
return assetFileNameReturn(assetsDir, 'application')
}

0 comments on commit 6f31cb6

Please sign in to comment.