-
-
Notifications
You must be signed in to change notification settings - Fork 6.3k
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
Improve usefulness of 'vue inspect' command /w chainWebpack #881
Comments
Note: we are probably going to implement something like this inside webpack-chain so it's also usable in Neutrino: neutrinojs/neutrino#328 |
Is there an example how to change / override a definition like this:
which is defined in |
@mediaessenz you can use webpackConfig
.plugin('extract-css')
.tap(args => newArgs); So if you wanted to change the options, which is the first arg: webpackConfig
.plugin('extract-css')
.tap(([options, ...args]) => [newOptions, ...args]); |
@eliperelman thanks for your answer, but I stil don't know how to do this inside the vue.config.js |
@eliperelman Thanks again, I got it now!
inside my vue.config.js do the job! |
LGTM, although if you want to make sure you pick up the other options, you should merge/assign: chainWebpack: config => {
config
.plugin('extract-css')
.tap(([options, ...args]) => [
Object.assign({}, options, { filename: 'Css/[name].css' }),
...args
]);
}, |
I thank you so much, you really save my eastern! |
If vue-cli works anything like Neutrino, then you can do this with an environment variable: chainWebpack: config => {
config
.plugin('extract-css')
.when(process.env.NODE_ENV === 'production', plugin => {
plugin.tap(([options, ...args]) => [
Object.assign({}, options, { filename: 'Css/[name].css' }),
...args
]);
});
}, |
If I try your snippet, I still get the changed filename, but when I try to inspect the development settings or try to start the serve/development mode with chainWebpack: config => {
config
.when(process.env.NODE_ENV === 'production', plugin => {
plugin.plugin('extract-css').tap(([options, ...args]) => [
Object.assign({}, options, { filename: 'Css/[name].css' }),
...args
])
})
}, |
@eliperelman I apprechiate your willingness to help here, but that's is not what this issue is meant for, and it's making it harder to track its progress if individual discussions are taking place in the comments. @mediaessenz Please use forum.vuejs.org or chat.vuejs.org to ask for help, we are active there as well. |
@LinusBorg Sorry, but I already tried to use the chat.vuejs.org, and did not get any answers :-( |
I understand that it can be frustrating when you need an answer and dont get it right away. But you will get one sooner or later. Highjacking Issues on github about hardly related topics is not the way to get your answers, please respect that. |
What problem does this feature solve?
Currently, the
vue inspect
command outputs a stringified version of the webpack config, and it's is very useful to get an overview of the final config resulting from all the plugins you are using.If you want to use
configureWebpack()
invue.config.js
to alter this config, this representation makes it easy to find the loader rule that you want to reach and change, for example.But the
chainWebpack
config gives you awebpack-chain
config, where all (most) pieces of the config have a name to access them by.For example, if I wanted to change some options of the
optimize-css-assets-webpack-plugin
, I can to do this:I like webpack-chain and think it' a great way to manipulate webpack's config, but for the above example, I must somehow be aware that the plugin's name in webpack-chain is 'optimize-css'.
So far, we haven't documented this anywhere, and the output of
vue inspect
doesn't help in that regard, either:So to learn that fact, I currently have to dig into the source of
@vue/cli-service
here, search through those files and then find this line:https://github.com/vuejs/vue-cli/blob/dev/packages/%40vue/cli-service/lib/config/prod.js#L22
The other approach would be to do something like this as a sort of debugging:
...which would give me an array of all plugin names (I may have gotten the exact webpack.chain syntax wrong, but that should be possible generally), and I have to guess which one the right one is.
I don't think that documenting it is enough, since documentation quickly can get out of sync, and there will also be numerous community-maintained plugins that don't necessarily adhere to the documentation standards we can provide for the official plugins.
What does the proposed API look like?
The output of
vue inspect
should also include the name for each piece of config that has one.(note the addition to the comment in the first line)
This surely isn't possible with the current implementation where we essentially pipe the already resolved webpack config through
javascript -stringify
(and replace plugin instances with the above json representation along the way).Rather, we would have to somehow walk through the webpack-chain
config
and build the json representation from that.I have no idea if this is possible, and won't have time to play around with the idea in the next few weeks, but maybe someone else has a great idea about how to tackle this.
It would greatly improve usability of the
chainWebpack
API.The text was updated successfully, but these errors were encountered: