Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow passing an array of assetMatch #65

Open
blimmer opened this issue Apr 23, 2019 · 5 comments
Open

Allow passing an array of assetMatch #65

blimmer opened this issue Apr 23, 2019 · 5 comments
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@blimmer
Copy link

blimmer commented Apr 23, 2019

In my case, I want to ignore all sourcemap files from my assetMatch. In digging into the code, I see that globby is used with the assetMatch parameter:

config.fileList = globby.sync(
config.options.assetMatch,
{ cwd: config.fullAssetPath }
).map(file => path.join(config.fullAssetPath, file))

I can't quite figure out how to craft a single string that does not match the map files. However, if assetMatch were allowed to be an array, this would be pretty trivial to do:

> const globby = require('globby')
undefined
> globby.sync(['**', '!**/*.map'], { cwd: 'dist' })
[ 'favicon.ico',
  'index.html',
  'manifest.json',
  'precache-manifest.7f28d7e92197dec38adda52d54e3c3f6.js',
  'robots.txt',
  'service-worker.js',
  'css/app.a3e5a163.css',
  'js/app.549d9a79.js',
  'js/chunk-vendors.429386d3.js',
  'img/icons/android-chrome-192x192.png',
  'img/icons/android-chrome-512x512.png',
  'img/icons/apple-touch-icon-120x120.png',
  'img/icons/apple-touch-icon-152x152.png',
  'img/icons/apple-touch-icon-180x180.png',
  'img/icons/apple-touch-icon-60x60.png',
  'img/icons/apple-touch-icon-76x76.png',
  'img/icons/apple-touch-icon.png',
  'img/icons/favicon-16x16.png',
  'img/icons/favicon-32x32.png',
  'img/icons/msapplication-icon-144x144.png',
  'img/icons/mstile-150x150.png',
  'img/icons/safari-pinned-tab.svg' ]

But right now, Joi validates that it's a string:

 ERROR  ValidationError: child "assetMatch" fails because ["assetMatch" must be a string]
ValidationError: child "assetMatch" fails because ["assetMatch" must be a string]
    at Object.exports.process (/Users/blimmer/code/myproj/node_modules/joi/lib/errors.js:203:19)

Could we make assetMatch a string OR an array?

@nicekiwi
Copy link
Collaborator

something like **/*.{!map} should work..

@blimmer
Copy link
Author

blimmer commented Apr 27, 2019

You'd think so, but I tried it out and it doesn't.

> const globby = require('globby')
undefined
> globby.sync('**/*.{!map}', { cwd: 'dist' })
[]
> globby.sync('**', { cwd: 'dist' })
[ 'favicon.ico',
  'index.html',
  'manifest.json',
  'precache-manifest.cbaea93cb3b25bc26c2c0f940194abce.js',
  'robots.txt',
  'service-worker.js',
  'css/app.a3e5a163.css',
  'js/app.4ecf32b6.js',
  'js/app.4ecf32b6.js.map',
  'js/chunk-vendors.429386d3.js',
  'js/chunk-vendors.429386d3.js.map',
  'img/icons/android-chrome-192x192.png',
  'img/icons/android-chrome-512x512.png',
  'img/icons/apple-touch-icon-120x120.png',
  'img/icons/apple-touch-icon-152x152.png',
  'img/icons/apple-touch-icon-180x180.png',
  'img/icons/apple-touch-icon-60x60.png',
  'img/icons/apple-touch-icon-76x76.png',
  'img/icons/apple-touch-icon.png',
  'img/icons/favicon-16x16.png',
  'img/icons/favicon-32x32.png',
  'img/icons/msapplication-icon-144x144.png',
  'img/icons/mstile-150x150.png',
  'img/icons/safari-pinned-tab.svg' ]

I tried a ton of different variations of this and I couldn't figure it out.

@nicekiwi nicekiwi added the enhancement New feature or request label May 7, 2019
@nicekiwi
Copy link
Collaborator

nicekiwi commented May 7, 2019

Hmmm seems reasonable. I'll look into it.

@nicekiwi nicekiwi self-assigned this May 7, 2019
@arthurmcgregor
Copy link

Trying to do exactly this!

bump

@nicekiwi nicekiwi added this to the 4.0.0 milestone Sep 30, 2019
@nicekiwi
Copy link
Collaborator

This feature has landed in the devel branch, though it is highly unstable atm.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants