link3151 link3152 link3153 link3154 link3155 link3156 link3157 link3158 link3159 link3160 link3161 link3162 link3163 link3164 link3165 link3166 link3167 link3168 link3169 link3170 link3171 link3172 link3173 link3174 link3175 link3176 link3177 link3178 link3179 link3180 link3181 link3182 link3183 link3184 link3185 link3186 link3187 link3188 link3189 link3190 link3191 link3192 link3193 link3194 link3195 link3196 link3197 link3198 link3199 link3200 link3201 link3202 link3203 link3204 link3205 link3206 link3207 link3208 link3209 link3210 link3211 link3212 link3213 link3214 link3215 link3216 link3217 link3218 link3219 link3220 link3221 link3222 link3223 link3224 link3225 link3226 link3227 link3228 link3229 link3230 link3231 link3232 link3233 link3234 link3235 link3236 link3237 link3238 link3239 link3240 link3241 link3242 link3243 link3244 link3245 link3246 link3247 link3248 link3249 link3250 link3251 link3252 link3253 link3254 link3255 link3256 link3257 link3258 link3259 link3260 link3261 link3262 link3263 link3264 link3265 link3266 link3267 link3268 link3269 link3270 link3271 link3272 link3273 link3274 link3275 link3276 link3277 link3278 link3279 link3280 link3281 link3282 link3283 link3284

[Vue.js] Clean outputDir except some files

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:


“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:


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.