Open jacekkarczmarczyk opened 4 years ago
this is also happening for me when running 'vue add pwa'
I have custom preset with templates
after vue create I have same bug:
If a file was exist, so working ok
If it is new file then you have bug with rename js
to ts
my temp solution for my case
api.render('./template');
api.postProcessFiles(function (files) {
const fs = require('fs');
const path = require('path');
const getFiles = require('./utils/getFiles');
// get files from ./templates
const templatePath = path.resolve(__dirname, './template');
const filesFromTemplate = getFiles(templatePath)
.map(
file => file
.replace(`${templatePath}/`, '')
.replace(/^__/g, '_')
.replace(/^_/g, '.'),
);
// remove from common list and manual save
for (const path of filesFromTemplate) {
if (!files[path]) {
throw new Error(`Not found ${path} from templates`)
}
fs.mkdirSync(api.resolve(path, '../'), { recursive: true });
fs.writeFileSync(api.resolve(path), files[path], { encoding: 'utf-8' })
delete files[path];
}
});
Also seeing this when doing vue add pwa
, that seems a bit overboard hey!
Version
4.5.7
Reproduction link
https://github.com/jacekkarczmarczyk/vue-cli-bug-files
Environment info
Steps to reproduce
clone repo, add a plugin (for example
vue add router
)What is expected?
.js files stay .js
What is actually happening?
.js files are converted to .ts
It's related to https://github.com/vuejs/vue-cli/issues/2676 However while adding a typescript plugin converting js files to ts might be justified then IMHO it doesn't seem to be the good behaviour when i'm adding unrelated plugins