-
-
Notifications
You must be signed in to change notification settings - Fork 6.3k
postProcessFiles files arg is an empty object #873
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
Comments
So I looked into it and this is not actually a bug.
So it's by design that you only get the files your plugin renders, not the whole rest of the project. You will have to get those files yourself. You can take a look at how @Akryum solved this in vue-cli-plugin-apollo: https://github.com/Akryum/vue-cli-plugin-apollo/blob/master/generator/index.js#L68-L91 |
Note: We should write a real guide on how to write a plugin that goes further than current documentation. In such a guide, we should address strategies for manipulating existing files. |
Hm, so what do you make of the PWA plugin that isn't adding the import line into main.js like it looks like it's trying to do here... |
@maurop123 Technically, you can just use plain |
Yea that could be good. The way the PWA plugin handles the main file in As for my use case, I'll follow Akryum's lead in the apollo plugin. Looks like it should work alright 😄 |
So when I select the pwa plugin when I create the project, the imports in
That's not right, is it? |
Version
3.0.0-alpha.13
Reproduction link
https://github.com/maurop123/vuecli3-test
Steps to reproduce
Starting from a project generated with vue cli 3
npm i -D cli-plugin-foobar
vue invoke cli-plugin-foobar
files: {}
Or with pwa plugin...
npm i -D @vue/cli-plugin/pwa
vue invoke pwa
What is expected?
In
postProcessFiles(files =>
of generator API, thefiles
args should contain the existing files.... right?What is actually happening?
In
postProcessFiles(files =>
of generator API, thefiles
args is an empty object.I was trying to add an import statement in main.js. I noticed that the pwa plugin seems to have the same code. When I tried running it, I noticed that main.js wasn't updated.
Where pwa generator index.js checks
if (main)
, main is probably undefined.The text was updated successfully, but these errors were encountered: