Skip to content

Commit

Permalink
Modify script detection function
Browse files Browse the repository at this point in the history
  • Loading branch information
theninthsky committed Aug 2, 2022
1 parent ea06c5a commit f2c4562
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 6 deletions.
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -420,9 +420,7 @@ plugins: [
const pages = pagesManifest.map(({ chunk, path, data }) => {
const assets = compilation.getAssets().map(({ name }) => name)
- const script = assets.find(name => name.includes(`/${chunk}.`) && name.endsWith('.js'))
+ const scripts = assets.filter(
+ name => (name.includes(`.${chunk}.`) || name.includes(`${chunk}.`)) && name.endsWith('.js')
+ )
+ const scripts = assets.filter(name => new RegExp(`[/.]${chunk}\\.(.+)\\.js$`).test(name))

if (data && !Array.isArray(data)) data = [data]

Expand Down
4 changes: 1 addition & 3 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,7 @@ module.exports = (_, { mode }) => {
templateContent: ({ compilation }) => {
const pages = pagesManifest.map(({ chunk, path, data }) => {
const assets = compilation.getAssets().map(({ name }) => name)
const scripts = assets.filter(
name => (name.includes(`.${chunk}.`) || name.includes(`${chunk}.`)) && name.endsWith('.js')
)
const scripts = assets.filter(name => new RegExp(`[/.]${chunk}\\.(.+)\\.js$`).test(name))

if (data && !Array.isArray(data)) data = [data]

Expand Down

0 comments on commit f2c4562

Please sign in to comment.