Skip to content

Commit

Permalink
Make sure to replace only once
Browse files Browse the repository at this point in the history
  • Loading branch information
paypro-leon committed Jan 9, 2024
1 parent 70ca392 commit f907070
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions package/rules/file.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ module.exports = {
type: 'asset/resource',
generator: {
filename: (pathData) => {
let path = dirname(pathData.filename)
const path = dirname(pathData.filename)
const includePath = includePaths.find((includePath) => path.includes(includePath))

Check failure on line 11 in package/rules/file.js

View workflow job for this annotation

GitHub Actions / JS Lint (ubuntu-latest, 14.x)

'includePath' is already declared in the upper scope on line 11 column 13

Check failure on line 11 in package/rules/file.js

View workflow job for this annotation

GitHub Actions / JS Lint (ubuntu-latest, 16.x)

'includePath' is already declared in the upper scope on line 11 column 13

includePaths.forEach((includePath) => {
path = path.replace(`${includePath}`, '')
})
const folders = path
.replace(`${includePath}`, '')
.split('/')
.filter(Boolean)

const folders = path.split('/').filter(Boolean)
const foldersWithStatic = ['static', ...folders].join('/')

return `${foldersWithStatic}/[name]-[hash][ext][query]`
}
}
Expand Down

0 comments on commit f907070

Please sign in to comment.