Open tbl0605 opened 4 years ago
your src/App.vue
was overwritten by @vue/cli-plugin-router
template render order is @vue/cli-service template-> your plugin template -> @vue/cli-plugin-router
.
I have another workaround, modify the preset.json like this
{
"useConfigFiles": true,
"plugins": {
"@vue/cli-plugin-babel": {},
"@vue/cli-plugin-eslint": {
"config": "prettier",
"lintOn": [
"save"
]
},
+ "@vue/cli-plugin-router": {
+ "historyMode": true
+ }
},
- "router": true, // legacy support
- "routerHistoryMode": true,
"vuex": true,
"cssPreprocessor": "dart-sass"
}
this preset leads to expected render order. releated code.
maybe Vue CLI needs another order control mechanism
like tapable/webpack-chain?(personal opinion)
your
src/App.vue
was overwritten by@vue/cli-plugin-router
template render order is
@vue/cli-service template-> your plugin template -> @vue/cli-plugin-router
.I have another workaround, modify the preset.json like this
{ "useConfigFiles": true, "plugins": { "@vue/cli-plugin-babel": {}, "@vue/cli-plugin-eslint": { "config": "prettier", "lintOn": [ "save" ] }, + "@vue/cli-plugin-router": { + "historyMode": true + } }, - "router": true, // legacy support - "routerHistoryMode": true, "vuex": true, "cssPreprocessor": "dart-sass" }
this preset leads to expected render order. releated code.
maybe Vue CLI needs another
order control mechanism
like tapable/webpack-chain?(personal opinion)
Thank you very much fangbinwei for your advice, I'll try that out. I didn't know about the rendering order stuff, for me the user preset should always be applied at very last (on top of other presets), that would be more logical, no?
My actual preset is the one I've saved using vue create
and strangely its content is far from the example you give or from those seen at https://cli.vuejs.org/guide/plugins-and-presets.html#presets
At least, there should be some warning about rendering order in the official guide, and at best vue-cli (or vue-router?) should save the presets like the examples given at https://cli.vuejs.org/guide/plugins-and-presets.html#presets
Also just my personal opinion ;)
I agree, rendering order should be mentioned in document. ✋And I guess you generated preset by vue cli 3? I tested version 4.1.2, it works.
I agree, rendering order should be mentioned in document. ✋And I guess you generated preset by vue cli 3? I tested version 4.1.2, it works.
Yes, I generated it using vue-cli 3 and reused it for vue-cli 4. My preset maybe worked correctly for vue-cli 3, but I only created a customized App.vue file very recently (to use with vue-cli 4).
Bump on this. I'm running into the same issue except with the vuetify cli plugin. I wish there could be a way to manually specify at what point the generator template (or certain files within it) get copied over
Version
4.1.2
Reproduction link
https://github.com/tbl0605/vue-cli-plugin-preset-bug-demo
Environment info
Steps to reproduce
create a new project using:
What is expected?
The file src/App.vue in project vue-demo-app should be overwritten by file generator/template/src/App.vue from preset vue-cli-plugin-preset-bug-demo
This problem does not occur with any other file that I'll add to directory generator/template/
What is actually happening?
The content of the file src/App.vue in project vue-demo-app will exclusively be based on the file App.vue from @vue/cli-service without taking account of generator/template/src/App.vue from preset vue-cli-plugin-preset-bug-demo
I tested with other presets found on github and the same problem occurred with their App.vue files.
When I create a new project using following commands, everything works as expected:
I can also workaround this problem in preset vue-cli-plugin-preset-bug-demo by renaming generator/template/src/App.vue as generator/template/src/App.tmpl.vue and by adding a hook in generator/index.js to write App.tmpl.vue back to App.vue: