multiplegeorges / vue-cli-plugin-s3-deploy

A vue-cli plugin that uploads your built Vue.js project to an S3 bucket
MIT License
331 stars 51 forks source link

Allow passing an array of `assetMatch` #65

Open blimmer opened 5 years ago

blimmer commented 5 years ago

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:

https://github.com/multiplegeorges/vue-cli-plugin-s3-deploy/blob/992daeae58c4120d4c7fb7075287b76242a1bfcb/src/deployer.js#L31-L34

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 commented 5 years ago

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

blimmer commented 5 years ago

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 commented 5 years ago

Hmmm seems reasonable. I'll look into it.

arthurmcgregor commented 5 years ago

Trying to do exactly this!

bump

nicekiwi commented 4 years ago

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