I have a file "script.js" and now new "min.js" are repeatedly made such as script.min.min.js then script.min.min.js then script.min.min.min.js.
I'm guessing it has to do with how I en-queued my script in "functions.php" but don't know enough about this
deleting all files but original
wp_enqueue_script( 'theme-script', get_template_directory_uri() . '/js/script.js', array(), '20190731', true );
gulp.task('lint', () =>
gulp.src(['./js/*.js'])
.pipe(prettyError())
.pipe(eslint())
.pipe(eslint.format())
.pipe(eslint.failAfterError()));
gulp.task( 'scripts', gulp.series('lint', () =>
gulp.src('./js/*.js')
.pipe(terser())
.pipe(rename({ extname: '.min.js' })
.pipe(gulp.dest('./js'))));
I just want script.js and maybe script.min.js if necessary
The problem is that you are minifying your scripts and placing them in the same directory that they came from. So, the next time the minification runs, the minified scripts are re-minified and an extra
.min
is added to the file nameTypically, you want to move the scripts to a distribution folder of some sort. It might look like this:
Also, be sure to excluse the
dist
folder from version control (usually.gitignore
).