when using Vue.js with vue-cli and currently in my package.json before every script when running clean script to clean all build files except app.php and .htaccess files:
package.json
“scripts”: {
“watch”: “npm run clean && vue-cli-service build –mode development –watch –no-clean”,
“dev”: “npm run clean && vue-cli-service build –mode development –no-clean”,
“build”: “npm run clean && vue-cli-service build –no-clean”,
“clean”: “find ../outputDir/* -not -name ‘app.php’ -not -name ‘.htaccess’ -delete”
}
This is working fine on Linux OS but not on macOS and Windows. Is there any better solution to keep some files in outputDir so it will be stable on all OS?
Solution :
You can change the folder structure to something like this:
OutputDir
app.php
static
index.js
otherOutput.js
and then point the vue.js output to OutputDir/static, then you will not need –no-clean option and it will only delete the files inside the OutputDir/static and not OutputDir hence the app.php will be untouched. This should work on all platforms.